What is the output of the following code?
name = 'Alice' age = 30 print(f'{name} is {age} years old.')
{name} is {age} years old.
name is age years old.
Alice is 30 years old.
Error
What is the output of this code?
i = 0 while i < 3: print(i) i += 2
0 2
Infinite loop
0 1 2
0 1
Which of the following data structures in Python is mutable?
Tuple
None of the above
List
String
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)
It will print nothing.
Enter your name: Hello, [user's input]
Enter your name:
Hello, [user's input]
What will the following Python code snippet print?
def greet(name): print(f"Hello, {name}!") greet("Alice")
greet("Alice")
Hello, Alice!
Hello, name!
An error message.
What is the correct way to take integer input from the user in Python?
raw_input()
input()
int(input())
input(int())
Which of the following is NOT a valid variable name in Python?
my_variable
variable123
variable_name
123variable
Which loop is best suited for iterating over a sequence of elements like a list?
while loop
while
for loop
for
Both are equally suitable
What is the value of the expression: '5' + '3'?
'5' + '3'
15
53
8