IT/Programming Concepts) Midterm
Exam With Actual Questions & Verified
Answers,Plus Rationales/Expert
Verified For Guaranteed Pass
2025/2026 /Latest Update/Instant
Download Pdf
1. Which of the following is the correct data type to store a whole number in Python?
A. float
B. string
C. int
D. bool
Rationale: int is used to store whole numbers, while float is for decimals, string for
text, and bool for True/False values.
2. What is the output of print(5 + 3 * 2) in Python?
A. 16
B. 11
C. 10
D. 11
Rationale: Python follows operator precedence. Multiplication occurs before
addition: 3*2=6, then 5+6=11.
3. Which of the following is used to define a function in Python?
A. function
B. define
C. def
D. func
Rationale: Functions in Python are defined using the def keyword.
,4. What does len("Hello") return?
A. 4
B. 5
C. 6
D. Error
Rationale: len() counts the number of characters in a string. "Hello" has 5
characters.
5. Which operator is used for string concatenation in Python?
A. *
B. -
C. +
D. &
Rationale: The + operator joins two strings together in Python.
6. Which of the following is mutable in Python?
A. string
B. tuple
C. list
D. int
Rationale: Lists can be modified after creation. Strings, tuples, and integers are
immutable.
7. What is the result of 3 == 3.0 in Python?
A. False
B. True
C. Error
D. None
Rationale: Python considers an integer and a float with the same value as equal.
8. Which loop is guaranteed to execute at least once?
A. for loop
B. while loop
C. do-while loop
D. if statement
Rationale: Python does not have a do-while loop, so among standard loops, while
may execute zero times. This question is tricky; ensure understanding: in Python,
loops can execute zero times.
9. How do you add a single element 10 to a list numbers?
A. numbers.add(10)
B. numbers.append(10)
C. numbers.insert(10)
, D. numbers.push(10)
Rationale: append() adds a single element to the end of a list.
10. Which of the following is not a valid Python variable name?
A. my_var
B. _myvar
C. myVar1
D. 1myvar
Rationale: Variable names cannot start with a number.
11. What is the correct way to write a comment in Python?
A. // comment
B. <!-- comment -->
C. # comment
D. /* comment */
Rationale: Python uses # for single-line comments.
12. What will be the output of print(2 ** 3)?
A. 6
B. 9
C. 8
D. 8
Rationale: ** is the exponentiation operator: 2^3 = 8.
13. Which of the following is used to handle exceptions in Python?
A. try-except
B. catch
C. error
D. try-except
Rationale: try-except blocks catch and handle exceptions in Python.
14. Which of the following is a Python tuple?
A. [1,2,3]
B. {1,2,3}
C. (1,2,3)
D. <1,2,3>
Rationale: Parentheses denote tuples in Python.
15. Which of the following statements will convert x = "10" to an integer?
A. int("10")
B. int(x)
C. str(x)
D. float(x)
Rationale: int() converts strings representing integers to integer data types.