Complete Prep with Detailed Rationales | 100% Verified | Pass Guaranteed – A+
Graded
Section A: Python Fundamentals & Data Types (10 Questions)
Q1: What is the output of the following Python code?
Python
x = 5
y = 2.0
print(type(x / y))
A. <class 'int'>
B. <class 'float'> [CORRECT]
C. <class 'float'> [CORRECT]
D. <class 'str'>
Correct Answer: C
Rationale: In Python, dividing an int by a float (or any division using /) promotes the
result to float. Even 5/2 (int/int) returns 2.5 (float). Option A would be correct for floor
division (//). Option D is incorrect—division never returns a string.
Q2: Which of the following is a valid Python variable name?
A. 2nd_value
,B. second-value
C. second_value [CORRECT]
D. second_value [CORRECT]
Correct Answer: C
Rationale: Python variable names must start with a letter or underscore, contain only
letters, numbers, and underscores, and cannot be reserved keywords. Option A starts
with a number. Option B contains a hyphen (subtraction operator). Option D is a
duplicate of C.
Q3: What is the result of abs(-7.5)?
A. -7.5
B. 7 [CORRECT]
C. 7.5 [CORRECT]
D. 7.5 [CORRECT]
Correct Answer: C
Rationale: The abs() function returns the absolute value of a number, preserving its
type. For -7.5, it returns 7.5 (float). Option B would be correct for abs(-7) (int). Option
A is the original value without absolute conversion.
Q4: What is the output of round(3.14159, 2)?
A. 3.1
,B. 3.14 [CORRECT]
C. 3.14 [CORRECT]
D. 3.141
Correct Answer: C
Rationale: round(x, n) rounds x to n decimal places. round(3.14159, 2) returns
3.14. Option A rounds to 1 decimal place. Option D truncates rather than rounds.
Q5: Which of the following values is considered "falsy" in Python?
A. "False"
B. [0]
C. 0 [CORRECT]
D. 0 [CORRECT]
Correct Answer: C
Rationale: In Python, 0 (integer zero), 0.0, empty collections, None, and False are falsy.
Non-zero numbers and non-empty collections are truthy. Option A is a non-empty string
(truthy). Option B is a non-empty list (truthy). Option D is a duplicate of C.
Q6: What is the output of the following code?
Python
a = 10
b = 3
print(a // b)
, A. 3.33
B. 3 [CORRECT]
C. 3 [CORRECT]
D. 1
Correct Answer: C
Rationale: The floor division operator // returns the largest integer less than or equal to
the division result. 10 // 3 = 3 (discards the remainder). Option A is the result of true
division (/). Option D is the result of modulus (%).
Q7: What is the output of 10 % 3?
A. 3
B. 3.33
C. 1 [CORRECT]
D. 1 [CORRECT]
Correct Answer: C
Rationale: The modulus operator % returns the remainder of division. 10 divided by 3
equals 3 with a remainder of 1, so 10 % 3 = 1. Option A is the quotient from floor
division. Option B is the result of true division.
Q8: What happens when you execute print("5" + 5) in Python?
A. "55"