Which method is used to convert a string to uppercase in Python?
uppercase()
toUpperCase()
toUpper()
upper()
How can you convert the integer 10 to a string in Python?
10
int_to_str(10)
str(10)
toString(10)
10.to_string()
What is the value of 'x' after this code executes?
x = 5 if x == 5: x += 1 else: x -= 1
4
5
6
7
What is the value of the expression: '5' + '3'?
'5' + '3'
15
8
Error
53
What is the primary purpose of using functions in Python?
To increase the execution speed of the program.
To define data structures like lists and dictionaries.
To reduce the memory consumption of the program.
To make the code more readable and organized.
Which of the following is NOT a valid way to format a string in Python?
concat() function
concat()
% operator
%
f-strings
format() method
format()
Which comparison operator is used to check if two values are not equal?
==
<
!=
Which statement is true about the else block in a while loop?
else
while
It executes only if the loop contains a break statement.
break
It always executes after the loop finishes.
It executes only if the loop condition becomes false.
The else keyword cannot be used with a while loop.
What is the output of the following Python code snippet?
print(10 / 3)
3
3.3333333333333335
3.0
What is the output of the following Python code?
string = 'Hello, world!' print(string[7:12])
Hello
world!
world
ello,