Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
MID TERM EXAMINATION
Code : CCS 3074
Course : Introduction to Programming
Semester-Year : 2nd SEMESTER, 2023-24
Day-Date : Tuesday – 23 April 2024
Start Time : 07:15 PM
Finish Time : 08:15 PM
General Information for Students:
Question CO Markss Marks
No. No. Assigned Awarded
1 1 3
2 5 5
3 2 4
4 3 4
5 4 4
Total 20
➢ Read and follow the instructions for each question carefully.
➢ Answer all the questions.
➢ Write your name and ID on each page
➢ Calculators are not allowed.
Student Name: ___________________________________ Student ID: ____________
Page 1 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
[Link].1: [3 Marks]
(a): Differentiate between Compiler and Interpreter.
(b): Give an example of:
• High-level programming language.
• Low-level programming language.
Student Name: ___________________________________ Student ID: ____________
Page 2 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
[Link].2: Analyze the following code to find 5 mistakes, circle each mistake. [5 marks]
1 exam1 = int(input("Enter the first exam score: "))
2 exam2 = int(input("Enter the second exam score: "))
3 exam3 = int(input("Enter the third exam score: "))
4
5 average_score = exam1 + exam2 + Exam3 / 3
6
7 print("Your average score is: average_score")
8
9 if average_score > 90
10 print("First honor")
11 else average_score > 80:
12 print("Second honor")
13 else
14 print("Normal")
Rewrite the lines which contain mistakes after fixing them.
Line
Fixing the error
number
Student Name: ___________________________________ Student ID: ____________
Page 3 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
[Link].3: Show the output of the following code segments: [4 marks]
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]
import math Output:
num1 = 2
num2 = 4
if num1 > num2:
print(pow(num2,num1))
else:
print([Link](num2))
Student Name: ___________________________________ Student ID: ____________
Page 4 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
[Link].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:
Enter two integers: 1, 5
5 4 3 2 1
Student Name: ___________________________________ Student ID: ____________
Page 5 of 6
Islamic University الجامعة اإلسالمية
Faculty of Computer and كلية الحاسب اآللي ونظم
Information Systems المعلومات
[Link].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
Student Name: ___________________________________ Student ID: ____________
Page 6 of 6