Completed
Expressions, I/O, Type Conversion
Questions From This Challenge
Q1mcq1 mark
In Python, which operator has the highest precedence among the following: **, *, +, ==
** ✓
*
+
==
Q2mcq1 mark
Given the expression `10 + 2 * 3`, what determines that multiplication is performed before addition?
Operator precedence rules ✓
The order in which variables were declared
Alphabetical order of operators
Python always evaluates left to right regardless of operator type
Q3mcq1 mark
What data type does the input() function return by default in Python?
str (string) ✓
int
float
bool
Q4mcq1 mark
Which function is used to display output to the console in Python?
print() ✓
display()
output()
show()
Q5mcq1 mark
Which built-in function converts a string like "10" into an integer?
int() ✓
str()
float()
bool()
Q6mcq1 mark
When you add an int and a float in Python (e.g., 3 + 2.5), what type conversion occurs automatically?
Python implicitly converts the int to a float before adding ✓
Python implicitly converts the float to an int before adding
Python raises a TypeError since mixed types cannot be added
No conversion occurs; the result is stored as a string
Q7mcq1 mark
What happens when you try `int("abc")` in Python?
It raises a ValueError ✓
It returns 0
It returns None
It silently converts to the integer 97
Q8mcq1 mark
A student writes `print("Total = " + 25)` and gets a TypeError. What is the most likely cause and fix?
Cannot concatenate str and int directly; wrap 25 with str() ✓
print() cannot accept more than one argument
The + operator does not exist in Python
Strings cannot be printed using print()
Q9mcq1 mark
While tracing a program, a student finds that a variable meant to hold a whole number is instead printing with a decimal point (e.g., 10.0 instead of 10). What is the most likely cause?
The variable was assigned the result of a true division (/) instead of floor division (//) ✓
The variable name was misspelled
The print() function always adds .0 to numbers
Comments were placed incorrectly in the code
Q10output1 mark
What is the output of the following code?
print(2 + 3 * 4 - 6 / 2)
Correct output:
11.0Q11output1 mark
What is the output of the following code?
a = 5 b = 2.5 c = a + b print(c)
Correct output:
7.5Q12output1 mark
What is the output of the following code?
x = "25" y = int(x) + 5 print(y)
Correct output:
30Q13output1 mark
What is the output of the following code?
age = 15 message = "Age: " + str(age) print(message)
Correct output:
Age: 15Q14output1 mark
If the user enters 7, what is the output of the following code?
n = int(input()) print(n * 2)
Correct output:
14Q15output1 mark
What is the output of the following code?
a = 10 b = 20 print(a, b, a + b)
Correct output:
10 20 30