Mid-Term Programing
Mid-Term Programing
Page 1 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
Q.No.1: [3 Marks]
Page 2 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
Q.No.2: Analyze the following code to find 5 mistakes, circle each mistake. [5 marks]
Line
Fixing the error
number
Page 3 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
a. [2 marks]
x = 2 Output:
y = 2
z = 3
if (x >= y):
print("A")
if (x >= z):
print("B")
else:
print("C")
b. [2 marks]
Page 4 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
Q.No.4: Write a Python program that takes two integers from the user then prints the numbers
between them (inclusively) in reverse order: [4 marks]
Expected output:
Page 5 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
Q.No.5: Develop a python function, ceilAndFloor, that applies both the ceiling and floor
functions on a decimal number. The function takes a float number as an argument and returns
its ceiling and floor values: [4 marks]
Expected behaviour:
c, f = ceilAndFloor(2.7) → c is 3 and f is 2
Page 6 of 6