WorksheetsPython- if -ifelse-elif
Total questions: 30
Worksheet time: 15mins
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
What is the output?
condition
True
Program has a syntax error.
3 > 2
What is the output?
True
False
condition1
condition2
What is the output?
more than 7
more than 23
spam
7
What is the output?
250.0
200.0
300.0
350.0
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What is the output?
True
NIL
True
NIL
True
NIL
NIL
What is the output?
level 3
level 3
level 1
level 3
level 1
NIL
level 3
level 2
level 1
NIL
What is the output?
40
15.0
30
25.0
If else statement
Outputs a message on the screen
Gets data from the user
A decision
A loop controlled by a decision
It is possible to execute both the (block of) statements under if and the else clauses at the same time.
Yes
No
To execute a Python program, you need a Python interpreter.
True
False
What would be the result of 3 ** 3
(a)
What would be the result of 9 // 7
(a)
What would be the reult of 9 % 7
(a)
Text to be output to the screen should be enclosed by " "
True
False
What is the output of this code?
click = True
Like = 0
if click:
Like = Like + 1
print(Like)
0
1
2
3
What is the output of the following code?
What is the output of following code
Temperature = 20
Thermo = 15
if Temperature < 15:
Thermo = Thermo + 5
print(Thermo)
20
15
25
10
What is the output of the following code?
Time = "Day"
Sleepy = False
Pajamas = "Off"
if Time == "Night" and Sleepy == True:
Pajamas = "On"
print(Pajamas)
off
on
False
Day
What will be the output of the following code?
def max(a, b):
if a > b:
print('a is the max')
else:
print('b is the max')
max(1,2)
1 is the max
a is the max
2 is the max
b is the max
Which of the following statements are correct?
(Select 2 Answers)
If is a conditional statement
If is used for looping
If is used for comparing and decision making
If is used for error handling
What will the be the output of the following code?
if (10<0) and (0 <-10):
print(“A”)
else:
print(“B”)
A
B
AB
BA
Is the following statement True of False?
Boolean variables can be used as conditions in an IF statement.
True
False
What is the output of the following code?
a = "b"
if True or True:
a = "a"
print(a * 2)
bb
aa
ab
ba
Is the following statement true or false?
More than one condition cannot be used with an IF statement.
True
False
