PROGRAMMING (PYTHON) QUESTION
EXAM WITH RATIONALES
1. What is Python?
A) Low-level programming language
B) High-level programming language
C) Assembly language
D) Machine language
Answer: B
Rationale: Python is a high-level, interpreted programming language that
emphasizes code readability and simplicity. It's not low-level (A), assembly (C), or
machine language (D), which are closer to hardware.
2. Which of the following is the CORRECT way to print output in Python 3?
A) print "Hello"
B) echo "Hello"
C) print("Hello")
D) System.out.println("Hello")
Answer: C
Rationale: In Python 3, print() requires parentheses: print("Hello"). Option A is
Python 2 syntax, B is bash, and D is Java syntax.
3. What data type is the value: 42?
A) String
B) Float
C) Integer
D) Boolean
Answer: C
Rationale: 42 is an integer (int) - a whole number without decimal points. String
would be "42", float would be 42.0, and boolean would be True/False.
,4. Which of the following is a VALID variable name in Python?
A) 2myVariable
B) my_variable
C) my-variable
D) var$iable
Answer: B
Rationale: my_variable is valid: starts with letter, contains only
letters/numbers/underscores. Option A starts with number (invalid), C has hyphen
(invalid), D has $ (invalid).
5. What is the output of: print(type(3.14))?
A) int
B) str
C) float
D) double
Answer: C
Rationale: 3.14 is a float (floating-point number) in Python. Python doesn't have a
separate "double" type - floats are double-precision by default.
6. What data type is: True?
A) Integer
B) String
C) Boolean
D) Float
Answer: C
Rationale: True is a Boolean value (bool), one of two possible values: True or
False. Not an integer (A), string (B), or float (D).
7. Which operator is used for exponentiation in Python?
A) ^
B) **
C) pow()
D) ^^
, Answer: B
Rationale: ** is the exponentiation operator: 2**3 = 8. ^ is bitwise XOR, pow() is
a function (not operator), ^^ is invalid.
8. What is the result of: 10 // 3?
A) 3.33
B) 3
C) 3.0
D) 1
Answer: B
Rationale: // is floor division (integer division): 10//3 = 3 (discards decimal). /
would give 3.33, % would give remainder 1.
9. What is the result of: 10 % 3?
A) 3
B) 1
C) 3.33
D) 0
Answer: B
Rationale: % is the modulo operator (remainder): 10÷3 = 3 remainder 1, so 10%3
= 1.
10. Which of the following creates a string?
A) 42
B) True
C) "Hello"
D) 3.14
Answer: C
Rationale: "Hello" with quotes creates a string (str). 42 is int, True is bool, 3.14 is
float.