What will the following code snippet print?
tuple1 = (1, 2, 3) tuple2 = (4, 5, 6) print(tuple1 + tuple2)
Error
[1, 2, 3, 4, 5, 6]
(1, 2, 3, 4, 5, 6)
(1, 2, 3)(4, 5, 6)
What is the output of this code?
i = 0 while i < 3: print(i) i += 2
0 1
0 2
Infinite loop
0 1 2
What is the output of the following Python code snippet?
print(True and False or True)
True
False
None
What is the correct way to access the third element of a list named 'my_list' in Python?
my_list[3]
my_list(2)
my_list.get(3)
my_list[2]
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 time complexity of checking if an element is present in a Python set?
O(log n)
O(n)
O(n log n)
O(1)
How many times will the word 'Hello' be printed?
for i in range(3): print('Hello')
0
3
1
2
What is a lambda function in Python?
A function that recursively calls itself.
A small, anonymous function defined using the 'lambda' keyword.
A function that takes another function as an argument.
A function defined using the 'def' keyword.
How can you retrieve the value associated with the key 'name' in a dictionary named 'my_dict'?
my_dict.name
my_dict.get('name')
my_dict['name']
Both option1 and option3
What is the correct way to add a new key-value pair to an existing dictionary in Python?
my_dict + {'city': 'New York'}
my_dict.insert('city', 'New York')
my_dict['city'] = 'New York'
my_dict.append('city', 'New York')