You are on page 1of 4

Kingdom of Saudi Arabia ‫المملكة العربية السعودية‬

Ministry of Education ‫وزارة التعليم – جامعة جازان‬


Jazan University ‫كلية علوم الحاسب و تقنية المعلومات‬
College of Computer Science &
Information Technology

Assignment 2

Student name: Student ID:

Course name: Introduction to Computing-COMP111 Section #:

Total Grade: /15

*Submit your work in a pdf format.


*No handwriting
*Each question worth 3 marks
*Do not use any compiler for the best learning outcomes

Question 1) Write the output of the following program.

a = 3
b = 2
if a > b:
print("a is greater than b")
print(a*b)
Kingdom of Saudi Arabia ‫المملكة العربية السعودية‬
Ministry of Education ‫وزارة التعليم – جامعة جازان‬
Jazan University ‫كلية علوم الحاسب و تقنية المعلومات‬
College of Computer Science &
Information Technology

Question 2) Convert the following flow chart into a program.

Question 3) write a program that use a while loop to display the following output:

The Output:

10
8
6
4
2
0
Kingdom of Saudi Arabia ‫المملكة العربية السعودية‬
Ministry of Education ‫وزارة التعليم – جامعة جازان‬
Jazan University ‫كلية علوم الحاسب و تقنية المعلومات‬
College of Computer Science &
Information Technology

Question 4) Write the output of the following code.

lowest_value= 200
print('before',lowest_value)
for x in [190,250,100,50,10,150,30]:
if x < lowest_value:
lowest_value = x
print('current lowest value: ',lowest_value, 'current for element: ', x)
print('the lowest value is ', lowest_value)

Question 5) find the four errors in the following code and rewrite the code.
found = False
print('Before, found)
for x in [8,41,66,3,40,75,15]
if x = 3:
found = True
print found, x)
print('after', found)
Kingdom of Saudi Arabia ‫المملكة العربية السعودية‬
Ministry of Education ‫وزارة التعليم – جامعة جازان‬
Jazan University ‫كلية علوم الحاسب و تقنية المعلومات‬
College of Computer Science &
Information Technology

You might also like