Computer Programming - Objective Questions & Answers
Chapter 1: Introduction to Programming
1. What is the main purpose of a programming language?
a) To perform manual calculations
b) To communicate with the computer
c) To create electrical circuits
d) To manage hardware manually
Answer: b) To communicate with the computer
2. Which of the following is a high-level programming language?
a) Assembly
b) C++
c) Machine code
d) Binary
Answer: b) C++
3. Which of these is NOT a characteristic of a programming language?
a) Syntax
b) Semantics
c) Hardware
d) Compiler
Answer: c) Hardware
4. What is the purpose of an interpreter?
a) Converts high-level code into machine code line by line
b) Translates the entire program at once
c) Only executes programs without translating
d) Connects different computers
Answer: a) Converts high-level code into machine code line by line
5. Which of the following is a low-level programming language?
a) Python
b) Java
c) Assembly
d) JavaScript
Answer: c) Assembly
Chapter 2: Data Types and Type Conversion
6. Which of the following is a numeric data type in Python?
a) Tuple
b) String
c) Integer
d) Dictionary
Answer: c) Integer
7. Which data type is immutable in Python?
a) List
b) Tuple
c) Set
d) Dictionary
Answer: b) Tuple
8. What will bool(0) return in Python?
a) True
b) False
c) 0
d) None
Answer: b) False
9. Which function is used for explicit type casting to an integer in Python?
a) str()
b) int()
c) float()
d) bool()
Answer: b) int()
10. What is the result of type('Hello') in Python?
a) int
b) str
c) list
d) char
Answer: b) str
Chapter 3: Algorithms and Flowcharts
11. Which of these is a characteristic of a good algorithm?
a) It must have a clear and definite end
b) It should contain infinite loops
c) It must always use recursion
d) It should be complex
Answer: a) It must have a clear and definite end
12. Which symbol represents a decision step in a flowchart?
a) Rectangle
b) Diamond
c) Oval
d) Arrow
Answer: b) Diamond
13. What does an oval symbol in a flowchart represent?
a) Input/output
b) Decision
c) Start/End
d) Process
Answer: c) Start/End
14. Which of the following is an example of an algorithm type?
a) Flowchart
b) Sorting
c) Pseudo-code
d) Diagram
Answer: b) Sorting
15. What is the purpose of a flowchart?
a) To execute Python code
b) To graphically represent an algorithm
c) To store data in a program
d) To convert high-level code to machine code
Answer: b) To graphically represent an algorithm
Chapter 4: Control Statements
16. Which of the following is a conditional statement in Python?
a) for
b) if
c) while
d) loop
Answer: b) if
17. Which statement is used to exit a loop in Python?
a) pass
b) continue
c) break
d) skip
Answer: c) break
18. Which loop executes at least once before checking the condition?
a) for
b) while
c) do-while
d) nested
Answer: c) do-while
19. Which keyword is used for multiple conditions in Python?
a) elseif
b) else if
c) elif
d) otherwise
Answer: c) elif
20. What will be the output of the following code?
for i in range(3):
print(i)
a) 1 2 3
b) 0 1 2
c) 0 1 2 3
d) 1 2
Answer: b) 0 1 2