
Python Conditional Statements-Gr-11
Authored by nalini chandran
Computers
University
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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
2.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Which one of the following if statements will not execute successfully:
if (1, 2):
print('foo')
if (1, 2):
print('foo')
if (1, 2):
print('foo')
if (1, 2): print('foo')
3.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What signifies the end of a statement block or suite in Python?
end
}
A line that is indented less than the previous line
A comment
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code snippet:
if 'bar' in {'foo': 1, 'bar': 2, 'baz': 3}:
print(1)
print(2)
if 'a' in 'qux':
print(3)
print(4)
4
1
2
3
4
It doesn’t generate any output.
1
2
4
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The following if/elif/else statement will raise a KeyError exception:
1 d = {'a': 0, 'b': 1, 'c': 0}
2
3 if d['a'] > 0:
4 print('ok')
5 elif d['b'] > 0:
6 print('ok')
7 elif d['c'] > 0:
8 print('ok')
9 elif d['d'] > 0:
10 print('ok')
11 else:
12 print('not ok')
False
True
6.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Which of the following are valid if/else statements in Python, assuming x and y are defined appropriately:
if x < y: print('foo'); print('bar'); print('baz')
if x < y: print('foo')
elif y < x: print('bar')
else: print('baz')
if x < y: print('foo') else: print('bar')
if x < y: if x > 10: print('foo')
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is value of this expression:
'a' + 'x' if '123'.isdigit() else 'y' + 'b'
'axb'
'ax'
'axyb'
'ab'
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?