What is the output of the following code?
name = 'Alice' age = 30 print(f'{name} is {age} years old.')
Error
name is age years old.
Alice is 30 years old.
{name} is {age} years old.
Can a Python function return multiple values?
Only if the values are of the same data type.
Yes, by separating the values with commas, effectively returning a tuple.
No, a function can only return a single value.
Yes, by using multiple 'return' statements within the function.
How many times will the word 'Hello' be printed?
i = 0 while i < 3: print('Hello') i += 1
Infinitely
4
2
3
What will the following Python code print to the console?
name = input("Enter your name: ") print("Hello,", name)
Enter your name: Hello, [user's input]
Hello, [user's input]
It will print nothing.
Enter your name:
What is the correct way to print 'Hello, World!' in Python?
print('Hello, World!')
echo 'Hello, World!'
console.log('Hello, World!')
System.out.println('Hello, World!')
What will the following Python code snippet print?
def greet(name): print(f"Hello, {name}!") greet("Alice")
Hello, name!
Hello, Alice!
greet("Alice")
An error message.
What is the correct way to access the third element of a list named 'my_list' in Python?
my_list.get(3)
my_list(2)
my_list[2]
my_list[3]
What is the time complexity of checking if an element is present in a Python set?
O(log n)
O(n log n)
O(n)
O(1)
What is the value of the expression: '5' + '3'?
'5' + '3'
15
53
8
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]