What will the following Python code snippet print?
def greet(name): print(f"Hello, {name}!") greet("Alice")
Hello, name!
greet("Alice")
Hello, Alice!
An error message.
What is the output of the following Python code snippet?
print(True and False or True)
True
None
False
Error
What is the value of the expression: '5' + '3'?
'5' + '3'
8
53
15
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 get user input and store it in a variable named 'name'?
name = print('Enter your name:')
input('Enter your name:') = name
print('Enter your name:') = name
name = input('Enter your name:')
What is the correct way to print 'Hello, World!' in Python?
console.log('Hello, World!')
print('Hello, World!')
System.out.println('Hello, World!')
echo 'Hello, World!'
x = 5 if x > 10: print('A') elif x > 3: print('B') else: print('C')
B
C
A
The code will result in an error.
What is the time complexity of checking if an element is present in a Python set?
O(n)
O(log n)
O(n log n)
O(1)
Which loop is best suited for iterating over a sequence of elements like a list?
for loop
for
while loop
while
Both are equally suitable
None of the above
How can you retrieve the value associated with the key 'name' in a dictionary named 'my_dict'?
my_dict.get('name')
my_dict['name']
my_dict.name
Both option1 and option3