What will the following code print?
my_set = {1, 2, 3} my_set.add(3) print(my_set)
Error
{1, 2, 3}
{3, 1, 2}
{1, 2, 3, 3}
What will this code snippet print?
x = 10 if x > 5: if x < 15: print('Yes') else: print('No')
An error message
YesNo
No
Yes
How can you convert the integer 10 to a string in Python?
10
toString(10)
int_to_str(10)
str(10)
10.to_string()
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 is the maximum number of arguments a lambda function can take?
Unlimited
255
2
1
What is the correct way to create a string literal containing both single and double quotes in Python?
"He said, 'Hello!'"
Both option 1 and 2 are correct
'He said, "Hello!"'
What is the output of the following Python code snippet?
print(True and False or True)
True
False
None
How many times will the word 'Hello' be printed?
i = 0 while i < 3: print('Hello') i += 1
Infinitely
4
3
Which function is used to convert a string to an integer in Python?
int()
str()
float()
bool()
What is the purpose of the break statement in a loop?
break
It prints the current value of the loop variable.
It exits the loop entirely.
It defines a new variable within the loop.
It skips the current iteration and continues to the next.