Section A: General Questions (50 Marks) : Instructions
Section A: General Questions (50 Marks) : Instructions
Instructions
1. The answers must be clear as possible to avoid any misunderstanding.
2. Any types of documents rather than the ones given by the invigilators are prohibited
3. In the MCQ part, each question has one (01) and only one good answer. Draw a table with 02 entries one for
question number and the other one for the letter corresponding to your good answer.
4. In the open answer questions, give a clear answer for each question with the maximum details according to the
total number of marks given
5. In the case study, your answers need to be oriented on practice. Give answers that can permit a technician to
achieve the goal. not just for the comprehension.
a. 1 2 3
b. Error
c. 1 2
d. None of the mentioned
9. What will be the output of the following Python expression if x=56.236??
a. 56.236
b. 56.23
c. 56.0000
d. 56.24
10. What will be the output of the following Python function?
len(["hello",2, 4, 6])
a. Error.
b. 6
c. 4
d. 3
11. Which function is called when the following Python program is executed?
f = foo()
print(f)
a. str()
b. format()
c. __str__()
d. __init__()
12. Which function is called when the following Python program is executed?
f = foo()
a. str()
b. __str__()
c. init()
d. __init__()
13. To add a new element to a list we use which Python command?
a. List1.addEnd(5).
b. List1.addLast(5)
2/5
c. List1.append(5)
d. List1.add(5)
14. What will be the output of the following Python program?
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
a. Error.
b. 0 1 2 0
c. 0 1 2
d. None of the above
15. What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
print(i)
a. 0 1 2 3
b. 1 2 3 4
c. a b c d
d. Error
16. In Python, a class is ___________ for a concrete object
a. A distraction.
b. A blueprint
c. A nuisance
d. An instance
17. The correct way to instantiate the following Dog class is:
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
a. Dog("Rufus", 3)
b. Dog.__init__("Rufus", 3)
c. Dog.create("Rufus", 3)
d. Dog()
18. With the object “buddy” we access to a class attribute, with
a. buddy.name;
b. buddyname;
c. buddy (name);
d. buddy__name
19. What’s the output of the following code snippet?
3/5
4...
5... def speak(self):
6... return "Woof!"
7...
8>>> class JackRussellTerrier(Dog):
9... def speak(self):
10... return "Arff!"
11...
12>>> bobo = JackRussellTerrier()
13>>> bobo.walk()
a. AttributeError:
b. object has no attribute 'walk';
c. *walking*
d. ; Arff!;
e. Woof!
20. In the above snippet what OOP principle is used in line 8
a. Class overriding;
b. Polymorphism;
c. Encapsulation;
d. Class overloading;
e. Inheritance
5/5
6/5