NEW
Font size
WorksheetsPython Homework : Term 2
Total questions: 10
Worksheet time: 10mins
What is the result of 5 > 3?
maybe
false
unknown
true
Which operator checks for equality in Python?
===
!=
==
=
What will the following code print:
x=10
if x = 10:
print('Ten')
else:
print('Not Ten')?
Not a Number
Ten
Twenty
Ten and a Half
print("5" + "5")
will return ?
5
10
25
55
What is the output of the following code:
for i in range(3):
print(i)?
0 1 2
3
-1
1.5
Which of the following is a valid for loop syntax in Python?
for int i = 0; i < 10; i++
for (int i = 0; i < 10; i++)
for i in range (1,4,1):
for (int i: 0 to 10)
What will happen if the condition in an if statement is false?
The code block inside the if statement is skipped.
The code block inside the if statement runs twice.
The program will terminate immediately.
The if statement executes without any conditions.
How can you combine an if statement with a for loop?
Use a for loop to iterate over a collection and include an if statement inside the loop to check a condition for each item.
Combine an if statement with a switch case for better clarity.
Use a while loop to check a condition before executing the loop.
Utilize a for loop to create a new collection without conditions.
What is the output of the following code:
x = 4
if x < 5:
print('Less than 5')
else:
print('5 or more')?
Equal to 4
Less than 5
Greater than 5
Less than or equal to 4
"apple" == "Apple" returns
True
False
Nothing
apple
