1. Which of the following is the most suitable definition of a function in
programming?
A. A function is a block of code that performs a specific task.
B. A function is used to store data.
C. A function is a sequence of statements that produce output.
D. A function is a method for creating variables.
Answer: A
Rationale: A function is a block of code that performs a specific task and can be
reused throughout the program.
2. What is the output of the following Python code?
python
Copy
x=5
y=2
print(x ** y)
,A. 7
B. 25
C. 10
D. 55
Answer: B
Rationale: The ** operator in Python represents exponentiation. So, 5 ** 2 = 25.
3. Which of the following is the correct syntax to define a class in Python?
A. class MyClass()
B. class MyClass:
C. class MyClass[]
D. define MyClass
Answer: B
Rationale: In Python, classes are defined using the class keyword followed by the
class name and a colon.
4. Which method can be used to add an element to the end of a list in Python?
A. add()
, B. insert()
C. append()
D. extend()
Answer: C
Rationale: The append() method adds an element to the end of the list.
5. In Java, what is the default value of a boolean variable?
A. True
B. False
C. Null
D. 0
Answer: B
Rationale: In Java, the default value of a boolean variable is false.
6. What does HTML stand for?
A. HyperText Markup Language
B. Hyper Transfer Markup Language
C. Home Text Markup Language
programming?
A. A function is a block of code that performs a specific task.
B. A function is used to store data.
C. A function is a sequence of statements that produce output.
D. A function is a method for creating variables.
Answer: A
Rationale: A function is a block of code that performs a specific task and can be
reused throughout the program.
2. What is the output of the following Python code?
python
Copy
x=5
y=2
print(x ** y)
,A. 7
B. 25
C. 10
D. 55
Answer: B
Rationale: The ** operator in Python represents exponentiation. So, 5 ** 2 = 25.
3. Which of the following is the correct syntax to define a class in Python?
A. class MyClass()
B. class MyClass:
C. class MyClass[]
D. define MyClass
Answer: B
Rationale: In Python, classes are defined using the class keyword followed by the
class name and a colon.
4. Which method can be used to add an element to the end of a list in Python?
A. add()
, B. insert()
C. append()
D. extend()
Answer: C
Rationale: The append() method adds an element to the end of the list.
5. In Java, what is the default value of a boolean variable?
A. True
B. False
C. Null
D. 0
Answer: B
Rationale: In Java, the default value of a boolean variable is false.
6. What does HTML stand for?
A. HyperText Markup Language
B. Hyper Transfer Markup Language
C. Home Text Markup Language