WorksheetsPython : Conditional Statement, Loops and Data Structure
Total questions: 20
Worksheet time: 10mins
What is the correct syntax of an if statement in Python?
if condition:
if(condition);
Which keyword is used to provide an alternative block in Python?
else
elseif
Which keyword is used for multiple conditions in Python?
elseif
elif
What will be the output of the code?
Greater
Error
In a nested if, an if statement is written:
Outside only
Inside another if
Which loop is used to iterate over a sequence in Python?
for
while
Which loop is used when the number of iterations is not known in advance?
for
while
What will be the output?
0 1 2
1 2 3
Which keyword is used to exit from a loop early?
break
exit
Which keyword is used to skip the current iteration of a loop?
continue
skip
Which operator is used for string concatenation in Python?
+
*
What will "Python" * 2 output?
PythonPython
Error
Which method is used to convert a string into lowercase?
lower()
toLowerCase()
Which function is used to find the length of a string?
length()
len()
Which data structure is mutable in Python?
List
Tuple
Which data structure allows duplicate values?
Set
List
Which symbol is used to define a dictionary in Python?
{}
[]
How do you access the value of a dictionary key?
dict.key
dict["key"]
Which data structure does not allow duplicate values?
Set
List
Which data structure maintains insertion order?
Dictionary
Set
