1. Which of the following represents an integer literal in Python?
A. 12.0
B. "12"
C. 12
D. '12'
Correct Answer: C. 12
Rationale:
An integer is a whole number without a decimal point. 12 is an integer literal. 12.0 is a float, and
"12" or '12' are strings because they are enclosed in quotation marks.
2. Which of the following represents a float value?
A. 1.2
B. 1
C. "1.2"
D. True
Correct Answer: A. 1.2
Rationale:
A float (floating-point number) contains a decimal point. "1.2" is a string, 1 is an integer, and
True is Boolean.
3. What data type is represented by 'twelve'?
A. Integer
B. Boolean
C. Float
D. String
Correct Answer: D. String
,Rationale:
Any value enclosed in single or double quotation marks is a string object in Python.
4. What is the purpose of the type() function?
A. Converts data types
B. Prints data
C. Determines the type of an object
D. Formats output
Correct Answer: C. Determines the type of an object
Rationale:
type() returns the class/type of an object (e.g., int, float, str, bool).
5. What does the int() function do?
A. Converts to string
B. Converts to float
C. Determines type
D. Converts a value to an integer object
Correct Answer: D. Converts a value to an integer object
Rationale:
int() casts a value into an integer when possible (e.g., int("5") → 5).
6. What is the result of the / operator in Python?
A. Always integer
B. Always string
C. Always float
D. Depends on operands
Correct Answer: C. Always float
Rationale:
In Python 3, / performs true division and always returns a float (e.g., 4/2 → 2.0).
, 7. Which operator performs exponentiation?
A. ^
B. *
C. //
D. **
Correct Answer: D. **
Rationale:
** raises a number to a power (e.g., 2**3 → 8). ^ is bitwise XOR.
8. What does // represent in Python?
A. Modulus
B. Float division
C. Integer (floor) division
D. Power
Correct Answer: C. Integer (floor) division
Rationale:
// performs floor division and returns an integer result (e.g., 5//2 → 2).
9. What does the += operator do?
A. Assigns
B. Compares equality
C. Adds and reassigns
D. Divides and reassigns
Correct Answer: C. Adds and reassigns
Rationale:
x += 3 is equivalent to x = x + 3.
10. Which comparison operator checks inequality?