wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Statements in Python

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

What signifies the end of a statement block or suite in Python?

a)

end

b)

}

c)

A comment

d)

A line that is indented less than the previous line

2.

What part of an if statement should be indented?

a)

The first line

b)

All of it

c)

The statements within it

d)

no indentation

3.

What is the output of this code?

spam = 7

if spam > 5:

print("five")

if spam > 8:

print("eight")

a)

eight

b)

five

c)

error

d)

nothing

4.

What is the output of this code?

num = 7

if num > 3:

print("3")

if num < 5:

print("5")

if num ==7:

print("7")

a)

5

b)

3

c)

7

d)

3

5

7

5.

What is the result of this code?

if 1 + 1 == 2:

if 2 * 2 == 8:

print("if")

else:

print("else")

a)

There is no output

b)

if

c)

else

d)

if

else

6.

Interpret the error in the given program and choose the right statement among the given options:


num=int(input("Enter a number:"))

if num>99:

print("Number is three digit")

a)

num=int(input("Enter a number:"))

if num>99:

print("Number is three digit")

b)

num=int(input("Enter a number:"))

if NUM>99:

PRINT("Number is three digit")

7.

If the given condition in 'if block' stands false, the flow of the program shifts to 'else' part.

a)

True

b)

False

8.

It is mandatory to indent the statements in the condition body. Otherwise it displays as error.

a)

True

b)

False

9.

In Python, the conditional statement is terminated with a ________ symbol.

a)

Semi Colon (;)

b)

Colon (:)

c)

Comma (,)

10.

‘If’ is a decision making statement

a)

TRUE

b)

FALSE

11.

There can be an else statement without an if statement

a)

FALSE

b)

TRUE

12.

In a Python program, a control structure:

a)

Directs the order of execution of the statements in the program

b)

Manages the input and output of control characters

c)

Defines program-specific data structures

d)

Dictates what happens before the program starts and after it terminates

13.

if ...else is _____________ statement in python.

a)

Looping statement

b)

Decision making

c)

iteration statement

14.

Find the output for the following code:

a)

Its Fragnant

b)

Rose

c)

Error

15.

What happens if the condition in an elif statement is false?

a)

The code block associated with the if statement will be executed

b)

The code block associated with the next elif statement or else statement will be checked and executed if its condition is true.

c)

The condition in the elif statement will be ignored

d)

The program will terminate immediately

16.

What will be the output of this code?

a)

b is the max

b)

a is the max

c)

a is the max

b is the max

d)

None of these

17.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

18.

Pieces of code that only run "under certain conditions":

a)

conditional statements

b)

control flow statments

c)

syntax

d)

variables

19.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
20.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday