Search Header Logo

Introduction to Python

Authored by Lakshmi.D Lakshmi

Computers

University

Used 1+ times

Introduction to Python
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code: print(5 > 3 and 2 < 4)?

2 > 4

True

False

5 < 3

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the difference between 'if', 'if-else', and 'if-elif-else' statements in Python.

'if' checks a condition, 'if-else' provides an alternative for false conditions, and 'if-elif-else' allows multiple conditions to be evaluated.

'if' is for checking types, 'if-else' is for importing modules, and 'if-elif-else' is for defining classes.

'if' and 'if-else' are the same, while 'if-elif-else' is a deprecated feature.

'if' is used for loops, 'if-else' is for defining functions, and 'if-elif-else' is for error handling.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of this code: x = 10; if x < 5: print('Low'); else: print('High')?

High

Low

Undefined

Error

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the 'break' statement in a loop?

To continue the loop indefinitely.

To exit a loop prematurely.

To skip the current iteration of the loop.

To pause the loop for a specified time.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Describe the use of the 'continue' statement in a loop.

The 'continue' statement skips the current iteration of a loop and continues with the next iteration.

The 'continue' statement repeats the current iteration of the loop.

The 'continue' statement pauses the loop for a specified time.

The 'continue' statement terminates the loop immediately.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a Boolean value in Python? Give an example.

True and False are the two Boolean values in Python.

On and Off

Yes and No

True and Maybe

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code output: for i in range(3): print(i)?

1, 2, 3

0, 1, 2

0 1 2

-1, 0, 1

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers