How many times will the following loop iterate?
for i in range(1, 5): print(i)
1
5
Infinitely
4
What is the output of the following Python code snippet?
print(10 / 3)
Error
3
3.3333333333333335
3.0
Which comparison operator is used to check if two values are not equal?
<
!=
==
Which method is used to convert a string to uppercase in Python?
toUpper()
uppercase()
upper()
toUpperCase()
What will the following code print?
set1 = {1, 2, 3} set2 = {3, 4, 5} print(set1.intersection(set2))
{1, 2, 4, 5}
{3}
{1, 2, 3, 4, 5}
How many times will the word 'Hello' be printed?
for i in range(3): print('Hello')
0
2
Which loop is best suited for iterating over a sequence of elements like a list?
Both are equally suitable
None of the above
while loop
while
for loop
for
What is the correct way to concatenate two strings, 'Hello' and 'World!', with a space in between?
'Hello' & ' ' & 'World!'
'Hello' + 'World!'
"Hello" + " " + "World!"
'Hello' + ' ' + 'World!'
What does the following code accomplish?
sum = 0 for i in range(1, 6): sum += i print(sum)
Finds the largest number between 1 and 5
Calculates the sum of numbers from 1 to 5
Calculates the factorial of 5
Prints the numbers from 1 to 5
What happens if a function doesn't explicitly use the 'return' keyword?
The function will return a random value.
The function will raise a SyntaxError.
The function will return 'None'.
The function will enter an infinite loop.