Which arithmetic operator is used to calculate the remainder of a division?
%
//
**
/
How many times will the following loop iterate?
for i in range(1, 5): print(i)
Infinitely
4
5
1
What is the purpose of the break statement in a loop?
break
It skips the current iteration and continues to the next.
It exits the loop entirely.
It prints the current value of the loop variable.
It defines a new variable within the loop.
Which method is used to convert a string to uppercase in Python?
uppercase()
toUpper()
toUpperCase()
upper()
What is the correct way to access the third element of a list named 'my_list' in Python?
my_list(2)
my_list[3]
my_list.get(3)
my_list[2]
What is the value of 'x' after this code executes?
x = 5 if x == 5: x += 1 else: x -= 1
7
6
What is the correct way to get user input and store it in a variable named 'name'?
input('Enter your name:') = name
name = print('Enter your name:')
name = input('Enter your name:')
print('Enter your name:') = name
Which method is used to add a new key-value pair to a dictionary?
append()
update()
insert()
add()
What is the output of the following Python code snippet?
print(type(5.0))
<class 'number'>
<class 'int'>
<class 'str'>
<class 'float'>
Which function is used to convert a string to an integer in Python?
float()
int()
str()
bool()