WORKSHEET (CONDITIONAL & ITERATIVE …

WORKSHEET (CONDITIONAL & ITERATIVE STATEMENTS) 1. What is the output of the following code?

if None: print("Hello")

False Hello Nothing will be printed Syntax error

2. The if...elif...else executes only one block of code among several blocks.

Choose one True

False

It depends on expression used.

There is no elif statement in Python.

3. What is the output of the following code?

for i in [1, 0]: print(i+1)

Choose one 2 1

[2, 1]

2 0

[2, 0]

4. In Python, for and while loop can have optional else statement?

Choose one Only for loop can have optional else statement

Only while loop can have optional else statement

Both loops can have optional else statement

Loops cannot have else statement in Python

5. What is the output of the following code?

while 4 == 4: print('4')

Choose one

4 is printed once

4 is printed four times

4 is printed infinitely until program closes

Syntax error

6. What is the output of the following code?

i = sum = 0 while i ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download