and Answers | 2026 Update | 100% Correct
1. What is the primary purpose of a variable in
programming?
A) To permanently store data on the hard drive
B) To hold a value that can change during program
execution
C) To comment code
D) To define a function
Answer: B
Rationale: A variable is a named storage location in
memory whose value can be changed while the program
runs. Permanent storage is for files/databases.
2. Which of the following is a valid variable name in most
programming languages?
A) 2var
B) var-name
1
,C) var_name
D) var name
Answer: C
Rationale: Many languages allow underscores but not
spaces, hyphens, or starting with digits.
3. What does the assignment operator (=) do?
A) Checks equality
B) Assigns the value on the right to the variable on the left
C) Compares two values
D) Creates a loop
Answer: B
Rationale: Single = assigns a value; equality check
uses ==.
4. Which data type is best for storing True or False?
A) int
B) float
C) bool
D) char
2
,Answer: C
Rationale: Boolean (bool) represents logical true/false.
5. What is the result of 7 // 2 in Python?
A) 3.5
B) 3
C) 4
D) Error
Answer: B
Rationale: Integer division (//) discards the remainder.
6. Which operator returns the remainder of division?
A) /
B) //
C) %
D) *
Answer: C
Rationale: Modulus operator % gives remainder.
7. What does print(type(3.14)) output?
A) <class 'int'>
3
, B) <class 'float'>
C) <class 'str'>
D) <class 'bool'>
Answer: B
Rationale: 3.14 is a floating-point number.
8. Which statement correctly declares a string?
A) name = "Alice"
B) name = Alice
C) name = 'Alice'
D) Both A and C
Answer: D
Rationale: Strings can use single or double quotes.
9. What is the output? x = 5; y = 2; print(x % y)
A) 2
B) 2.5
C) 1
D) 0
4