What will the following Python code snippet print?
mult = lambda x, y: x * y print(mult(5, 3))
15
mult(5, 3)
An error message.
lambda x, y: x * y
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 condition becomes false.
The else keyword cannot be used with a while loop.
It executes only if the loop contains a break statement.
break
Which of the following is NOT a valid variable name in Python?
123variable
variable_name
variable123
my_variable
What will the following code snippet print?
tuple1 = (1, 2, 3) tuple2 = (4, 5, 6) print(tuple1 + tuple2)
(1, 2, 3, 4, 5, 6)
Error
[1, 2, 3, 4, 5, 6]
(1, 2, 3)(4, 5, 6)
Which method is used to remove an element from a list by its value in Python?
remove()
pop()
delete()
discard()
Which method is used to convert a string to uppercase in Python?
toUpperCase()
uppercase()
upper()
toUpper()
What is the purpose of the break statement in a loop?
It skips the current iteration and continues to the next.
It prints the current value of the loop variable.
It defines a new variable within the loop.
It exits the loop entirely.
How many times will the word 'Hello' be printed?
i = 0 while i < 3: print('Hello') i += 1
4
2
3
Infinitely
What will the variable 'x' hold after this code executes?
x = 5 x %= 2
1
2.5
5
How can you convert the integer 10 to a string in Python?
10
str(10)
10.to_string()
toString(10)
int_to_str(10)