Which function is used to convert a string to an integer in Python?
bool()
str()
int()
float()
What is the correct way to create a string literal containing both single and double quotes in Python?
"He said, 'Hello!'"
'He said, "Hello!"'
Both option 1 and 2 are correct
What happens if a function doesn't explicitly use the 'return' keyword?
The function will raise a SyntaxError.
The function will return 'None'.
The function will return a random value.
The function will enter an infinite loop.
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 3 4
1 2 3 4 5
1 2 4 5
What will the following code snippet print?
x = 5 y = 2 * x print(y)
x * 2
10
5
2 * x
How many times will the following loop iterate?
for i in range(3, 8): print(i)
8
3
7
What is the primary purpose of using functions in Python?
To define data structures like lists and dictionaries.
To reduce the memory consumption of the program.
To increase the execution speed of the program.
To make the code more readable and organized.
Which loop is best suited for iterating over a sequence of elements like a list?
while loop
while
None of the above
Both are equally suitable
for loop
for
What is the correct way to print 'Hello, World!' in Python?
print('Hello, World!')
System.out.println('Hello, World!')
echo 'Hello, World!'
console.log('Hello, World!')
What will the following code print: print(10 > 5 and 'apple' == 'orange')?
print(10 > 5 and 'apple' == 'orange')
False
Error
10appleorange
True