Exam 3
Exam 3
(LNGG 1003)
ساعتان:مدة االمتحان :الرقن الجاهعي
9:11 – 09:11 :وقت االهتحاى :اسن الوعيد
االهتحاى النهائي للفصل األول
م9191-9102 : رقن الشعبة
Q1) Choose the correct answer
1, 2, 3, 4, 5 0, 1, 2, 3, 4, 5 0, 1, 2, 3, 4, 5 1, 2, 3, 4
7) Which of the following function is incorrect? (choose multiple)
10 11 17 20
10) What is the output of the following code?
x = 0
while x < 4:
x = x + 1
print("x is", x)
x is 2 x is 4 x is 5
X is 0
11) What is sum after the following loop terminates?
sum = 0
item = 0
while item < 5:
item += 1
sum += item
if sum >= 4:
continue
print(sum)
15 16 17 18
print(f(5))
The missing function body should be ________.
print(number) return "number" print("number") return number
f1()
print(x)
1 3 3 1 1 1 3 3
Q2) what is printed by the Python code?
Input Output
for z in [2, 4, 7, 9]:
print(z - 1)
n = 3
for x in [2, 5, 8]:
n = n + x
print(n)
def func(x):
return x – 1
print(func(3) * func(5))
Q4) Write program that let you enter 10 positive numbers, but if you enter a negative
number it quit.
Q5) Write a Python program to solve quadratic equations of the form 𝑎 +𝑏 +𝑐=0
Where the coefficients a, b, and c are real numbers taken from user. The two real
number solutions are derived by the formula
Q6) Write a function that takes a list and returns the first negative number.
Good Luck