Which statement is true about the else block in a while loop?
else
while
It always executes after the loop finishes.
It executes only if the loop contains a break statement.
break
It executes only if the loop condition becomes false.
The else keyword cannot be used with a while loop.
What will be the data type of the result of the following expression: 10 / 2?
10 / 2
Float
Boolean
Integer
String
How many expressions can a lambda function have?
Only one
None, it only takes arguments
As many as needed
Two
What will the following Python code print to the console?
name = input("Enter your name: ") print("Hello,", name)
Hello, [user's input]
Enter your name:
Enter your name: Hello, [user's input]
It will print nothing.
How many times will the following loop iterate?
for i in range(3, 8): print(i)
8
5
3
7
What is the output of the following code?
name = 'Alice' age = 30 print(f'{name} is {age} years old.')
name is age years old.
{name} is {age} years old.
Error
Alice is 30 years old.
Which arithmetic operator is used to calculate the remainder of a division?
%
**
/
//
What will be the output of this code snippet?
i = 0 while i < 5: i += 1 if i == 3: continue print(i)
1 2 3 4 5
1 2 4 5
1 2 3 4
0 1 2 4 5
How can you retrieve the value associated with the key 'name' in a dictionary named 'my_dict'?
my_dict.name
Both option1 and option3
my_dict['name']
my_dict.get('name')
What will the following code print: print(10 > 5 and 'apple' == 'orange')?
print(10 > 5 and 'apple' == 'orange')
True
False
10appleorange