Questions And Answers Practice Questions with
Solutions Newest | Already Graded A+
Section 1: Python Fundamentals & Data Types
Q1. What is the output of print("Hello" + " " + "World")?
A) HelloWorld
B) Hello World
C) Hello+World
D) Error
Correct Answer: B
Rationale: The + operator concatenates strings. "Hello" + " " + "World" produces
"Hello World" .
Q2. Which data type is the value 3.14 in Python?
A) int
B) float
C) str
D) bool
Correct Answer: B
Rationale: Any number with a decimal point is a float (floating-point number) in
Python .
Q3. What is the output of type()?
A) <class 'int'>
B) <class 'float'>
C) <class 'double'>
D) <class 'number'>
,Correct Answer: B
Rationale: The / operator always returns a float, even when the result is a whole
number. = 5.0 (float) .
Q4. Which is a valid variable name in Python?
A) 2cool
B) cool-variable
C) _coolVariable
D) cool variable
Correct Answer: C
Rationale: Variables must start with a letter or underscore, cannot start with a
digit, and cannot contain spaces or hyphens. _coolVariable is valid .
Q5. What is the output of print("Python"[2])?
A) P
B) y
C) t
D) h
Correct Answer: C
Rationale: Strings are zero-indexed. Index 2 is the third character: "P"(0), "y"(1),
"t"(2) .
Q6. What does len("Programming") return?
A) 10
B) 11
C) 12
D) 9
Correct Answer: B
Rationale: len() counts the number of characters, including letters. "Programming"
has 11 characters .
Q7. What is the output of print(3 ** 3)?
,A) 9
B) 27
C) 6
D) 12
Correct Answer: B
Rationale: ** is the exponentiation operator. 3 ** 3 = 3 × 3 × 3 = 27 .
Q8. What is the result of 15 % 4?
A) 3
B) 3.75
C) 0
D) 4
Correct Answer: A
Rationale: The % operator returns the remainder of a division. is 3 with a
remainder of 3 .
Q9. Which data type is immutable?
A) list
B) dict
C) set
D) tuple
Correct Answer: D
Rationale: A tuple cannot be changed after creation (immutable). Lists,
dictionaries, and sets are mutable .
Q10. What is the output of print(10 // 3)?
A) 3.33
B) 3
C) 4
D) 3.5
, Correct Answer: B
Rationale: // is the floor division operator. It performs division and returns the
integer part of the quotient. 10 // 3 is 3 .
Q11. What is the output of the following code?
python
x = 10
x += 5
print(x)
A) 5
B) 10
C) 15
D) 105
Correct Answer: C
Rationale: x += 5 is equivalent to x = x + 5. The variable starts at 10, becomes 15,
and prints 15 .
Q12. Which symbol begins a single-line comment in Python?
A) //
B) #
C) /* */
D) *
Correct Answer: B
Rationale: The # symbol begins a single-line comment in Python. Everything
after # on that line is ignored by the interpreter .
Q13. What is the output of print(type(True))?
A) <class 'int'>
B) <class 'bool'>
C) <class 'str'>
D) <class 'float'>