NEW
Font size
WorksheetsStatements in Python
Total questions: 20
Worksheet time: 11mins
What signifies the end of a statement block or suite in Python?
end
}
A comment
A line that is indented less than the previous line
What part of an if statement should be indented?
The first line
All of it
The statements within it
no indentation
What is the output of this code?
spam = 7
if spam > 5:
print("five")
if spam > 8:
print("eight")
eight
five
error
nothing
What is the output of this code?
num = 7
if num > 3:
print("3")
if num < 5:
print("5")
if num ==7:
print("7")
5
3
7
3
5
7
What is the result of this code?
if 1 + 1 == 2:
if 2 * 2 == 8:
print("if")
else:
print("else")
There is no output
if
else
if
else
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")
num=int(input("Enter a number:"))
if num>99:
print("Number is three digit")
num=int(input("Enter a number:"))
if NUM>99:
PRINT("Number is three digit")
If the given condition in 'if block' stands false, the flow of the program shifts to 'else' part.
True
False
It is mandatory to indent the statements in the condition body. Otherwise it displays as error.
True
False
In Python, the conditional statement is terminated with a ________ symbol.
Semi Colon (;)
Colon (:)
Comma (,)
‘If’ is a decision making statement
TRUE
FALSE
There can be an else statement without an if statement
FALSE
TRUE
In a Python program, a control structure:
Directs the order of execution of the statements in the program
Manages the input and output of control characters
Defines program-specific data structures
Dictates what happens before the program starts and after it terminates
if ...else is _____________ statement in python.
Looping statement
Decision making
iteration statement
Find the output for the following code:
Its Fragnant
Rose
Error
What happens if the condition in an elif statement is false?
The code block associated with the if statement will be executed
The code block associated with the next elif statement or else statement will be checked and executed if its condition is true.
The condition in the elif statement will be ignored
The program will terminate immediately
What will be the output of this code?
b is the max
a is the max
a is the max
b is the max
None of these
What is the output?
True
False
condition1
condition2
Pieces of code that only run "under certain conditions":
conditional statements
control flow statments
syntax
variables
The result of this program:
Friday = False
if Friday:
print "Jeans day!"
else:
print "Uniform day"
Jeans day
Today is Friday
Uniform day
Not Friday
