Questions And Correct Answers (Verified
Answers) Plus Rationale 2026 Q&A
SECTION 1: VARIABLES, DATA TYPES, & OPERATORS
1. Which of the following is a valid variable name in most programming
languages?
A) 2ndPlace
B) my-variable
C) _privateValue
D) class
Correct Answer: C | Rationale: Variable names typically cannot start with a
number (A), cannot contain hyphens (B), and cannot be reserved keywords like
"class" (D). Underscores (_) are allowed as the first character.
2. In Python, what data type is the value 3.14?
A) Integer
B) String
C) Float
D) Boolean
Correct Answer: C | Rationale: A number with a decimal point is a floating-point
number (float). An integer (A) has no decimal. A string (B) is text enclosed in
quotes. A boolean (D) is True/False.
3. What is the result of 10 // 3 in Python?
A) 3.33
B) 3
C) 4
D) 3.0
,Correct Answer: B | Rationale: The // operator performs integer (floor) division,
discarding the remainder. 10 divided by 3 is 3 with a remainder of 1, so the result
is 3. / (single slash) would return 3.33 (float).
4. What is the output of the following code?
python
x=5
y=2
print(x ** y)
A) 7
B) 10
C) 25
D) 32
Correct Answer: C | Rationale: The ** operator is the exponentiation (power)
operator. 5 raised to the power of 2 is 5 × 5 = 25.
5. Which operator is used to compare two values for equality in most languages
(e.g., Java, C++, Python)?
A) =
B) ==
C) !=
D) ===
Correct Answer: B | Rationale: == is the equality comparison operator. = is the
assignment operator. != means "not equal." === is strict equality in some
languages (JavaScript) but == is the standard.
6. What is the value of total after this code executes?
python
total = 0
total += 5
,total *= 2
total -= 3
A) 7
B) 10
C) 4
D) 13
Correct Answer: A | *Rationale: total starts at 0. +=5 makes it 5. =2 makes it 10. -
=3 makes it 7.
7. Which data type can only hold two possible values (True/False)?
A) Integer
B) Character
C) Boolean
D) Array
Correct Answer: C | Rationale: A Boolean (bool) data type represents logical
values: True or False (or 1/0 in some languages).
8. What is the result of "Hello" + " " + "World" in most languages?
A) "Hello World"
B) "HelloWorld"
C) Error
D) "Hello + World"
Correct Answer: A | Rationale: The + operator concatenates (joins) strings. Adding
a space string " " between them produces "Hello World".
9. A variable declared inside a function is known as a:
A) Global variable
B) Local variable
C) Constant
D) Parameter
, Correct Answer: B | Rationale: A local variable is declared within a function and
can only be accessed inside that function. A global variable (A) is declared outside
all functions and can be accessed anywhere.
10. What is the value of remainder after this code?
python
remainder = 17 % 5
A) 3
B) 2
C) 5
D) 3.4
Correct Answer: B | Rationale: The % operator is the modulus (remainder)
operator. 17 divided by 5 is 3 with a remainder of 2.
11. Which of the following is NOT a primitive data type in most languages?
A) int
B) float
C) string
D) char
Correct Answer: C | Rationale: In many languages (Java, C), String is a reference
type/object, not a primitive. However, in Python, everything is an object. This
question reflects classical terminology where primitives are int, float, char,
boolean.
12. What is the output of this code?
python
a = 10
b=3
print(a / b)