algorithms and programming languages 2022 2023 exams
algorithms and programming languages 2022 2023 exams
School/Faculty: NAHPI Department/Year: ALL/ Year 1 Lecturer(s): Dr. Ndukum. P, Tangu Achilis, Ndjock michel
Course Code: COME2201. Course Title: ALGORITHM AND PROGRAMMING LANGUAGES Course Credits: 4
Date:2022/2023 academic year Hall: Time: 2 hrs
Instructions: Answers ALL questions in an orderly manner
Page 1 of 3
11. What is a conditional statement in programming?
A) A loop that executes a set of instructions B) A way to define a variable C) A way
to branch the execution of a program based on a condition D) A data structure
12. Python code is converted to machine code using?
A) Compiler B) Interpreter C) debugger D) Linker
13. What is a parameter in a function?
A) A variable that is defined inside a function B) A variable that is passed into a
function C) A loop that executes a set of instructions D) A conditional
statement
14. Which of the following is not a way of representing algorithms?
A) Pseudo-code B) Structured English C) Flow charts D) Enumeration
15. What is the output of the following code in Python: print(10 // 3)
A) 3.3333 B) 3 C) 3.0 D) 3.33
16. What is the result of the following statement in python: 10>10?
A) 10 B) False C) false D) True
17. Which generation of programming languages uses mnemonics and symbols to
represent instructions?
A) Low-Level Languages B) Second-Generation Languages C) Fourth
Generation Languages D) High Level Languages
18. Which of the following factors will affect your choice for a programming language?
A) Cost B) Tool support C) Time D) Beauty
19. Which of the following is a type of loop in python?
A) do while B) for C) repeat D) foreach
20. What is the output of the following code in Python: print(2 ** 3)
A) 2 B) 3 C) 8 D) 6
21. Which of the following is not a characteristic of a good programming language?
A) Naturalness B) Completion C) Abstraction D) Efficiency
22. Which of the following is not a step in the program development lifecycle?
A) Maintenance B) Security C) Coding D) Problem Definition
23. Which symbol is used to represent a process in a flowchart?
A) Ellipse B) Rhombus C) Rectangle D) Parallelogram
24. Which python function is used to get input from the user?
A) print() B) int() C) input() D) read()
25. What is the output of the following code in Python: print("Hello" * 3)
A) Hello B) HelloHelloHello C) 9 D) Error
Page 2 of 3
SECTION B: Structural 20MRKS
1. Write a flowchart algorithm to that finds the smallest number among three numbers
and hence write a python implementation of the algorithm (10 mrks)
2. The following is a python program that calculates the average of 3 numbers. The
program will not run successfully, correct the code(4mrks)
number1 = input("Enter the first number: ")
if number > 0:
else:
a) Provide a value for number that will cause only the second if block to be executed
b) Provide a value for number that will cause only the first if block to be executed
c) Provide a value for number that will cause only the third if block to be executed
d) Provide a value for number that will cause the first and second if block to
executed
Page 3 of 3