What is the primary characteristic of a set in Python?
Unordered and immutable
Ordered and mutable
Unordered and mutable
Ordered and immutable
What will be the output of this code snippet?
i = 0 while i < 5: i += 1 if i == 3: continue print(i)
0 1 2 4 5
1 2 4 5
1 2 3 4
1 2 3 4 5
What is the correct way to concatenate two strings, 'Hello' and 'World!', with a space in between?
'Hello' + 'World!'
'Hello' & ' ' & 'World!'
"Hello" + " " + "World!"
'Hello' + ' ' + 'World!'
What will the following Python code snippet print?
x = 5 if x > 10: print('A') elif x > 3: print('B') else: print('C')
A
The code will result in an error.
C
B
What will the following code print: print(10 > 5 and 'apple' == 'orange')?
print(10 > 5 and 'apple' == 'orange')
10appleorange
False
True
Error
Which assignment operator in Python is used to perform floor division and assign the result?
%=
=
/=
//=
What is the correct way to get user input and store it in a variable named 'name'?
input('Enter your name:') = name
print('Enter your name:') = name
name = print('Enter your name:')
name = input('Enter your name:')
How many times will the following loop iterate?
for i in range(3, 8): print(i)
7
5
8
3
What is the output of the following Python code?
my_list = [1, 2, 3, 4, 5] print(my_list[1:3])
[1, 2, 3]
[3, 4]
[1, 2]
[2, 3]
What is a key limitation of lambda functions in Python compared to regular functions defined with def?
def
Lambda functions can only take a single argument.
Lambda functions cannot use the return statement.
return
Lambda functions can only contain a single expression.
Lambda functions cannot be assigned to variables.