What will the following Python code snippet print?
x = 5 if x > 10: print('A') elif x > 3: print('B') else: print('C')
B
The code will result in an error.
A
C
How many times will the following loop iterate?
for i in range(1, 5): print(i)
Infinitely
5
4
1
What is a key limitation of lambda functions in Python compared to regular functions defined with def?
def
Lambda functions can only contain a single expression.
Lambda functions cannot use the return statement.
return
Lambda functions can only take a single argument.
Lambda functions cannot be assigned to variables.
What is the output of the following Python code?
string = 'Hello, world!' print(string[7:12])
ello,
Hello
world!
world
What is the time complexity of checking if an element is present in a Python set?
O(n log n)
O(n)
O(1)
O(log n)
What will the following code snippet print?
x = 5 y = 2 * x print(y)
2 * x
10
x * 2
What is the maximum number of arguments a lambda function can take?
Unlimited
2
255
Which arithmetic operator is used to calculate the remainder of a division?
/
//
**
%
How many times will the word 'Hello' be printed?
i = 0 while i < 3: print('Hello') i += 1
3
Which of the following is NOT a valid variable name in Python?
variable123
variable_name
123variable
my_variable