What is the output of the following Python code snippet?
print(True and False or True)
None
Error
False
True
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: Hello, [user's input]
Enter your name:
It will print nothing.
How many times will the following loop iterate?
for i in range(3, 8): print(i)
7
5
3
8
What is the correct way to add a new key-value pair to an existing dictionary in Python?
my_dict.append('city', 'New York')
my_dict + {'city': 'New York'}
my_dict['city'] = 'New York'
my_dict.insert('city', 'New York')
What is the value of the expression: 10 > 5 and 3 < 1?
10 > 5 and 3 < 1
10
What will the following Python code snippet print?
x = 5 if x > 10: print('x is greater than 10') elif x > 3: print('x is greater than 3') else: print('x is less than or equal to 3')
x is less than or equal to 3
x is greater than 3
x is greater than 10
Can a Python function return multiple values?
No, a function can only return a single value.
Yes, by using multiple 'return' statements within the function.
Yes, by separating the values with commas, effectively returning a tuple.
Only if the values are of the same data type.
What is the maximum number of arguments a lambda function can take?
Unlimited
1
2
255
What is the output of the following Python code?
string = 'Hello, world!' print(string[7:12])
world
Hello
ello,
world!
What is the correct way to create a string literal containing both single and double quotes in Python?
'He said, "Hello!"'
"He said, 'Hello!'"
Both option 1 and 2 are correct