# Signed date this examination has 6 pages including

• anmolsandhu7766
• 6
• 100% (2) 2 out of 2 people found this document helpful

This preview shows page 1 - 4 out of 6 pages.

Signed: ___________________________________________ Date: __________________________ This examination has 6 pages (including this page). Please count the pages to make sure you have the complete exam. Good Luck! 1 | P a g e
CPSC111BV-Introduction to Computing: Fall 2019 Midterm Exam 2 – Muntaseer Salahuddin Y OU WILL BE EXPECTED TO WRITE PYTHON CODE ON THIS EXAM . I RECOMMEND THAT YOU DRAW VERTICAL LINES TO MAKE YOUR INDENTATION CLEAR , AS FOLLOWS : MULTIPLE CHOICE QUESTIONS – [10 points, 1 point each] i = 10 bob = False while !b: ##point A bob = True i //= 5 if i > 0: bob = False ##point B print(bob) 1. What is the value of b at point A in the code above? def foo(): if condition: do something do more things do something last foo()
2. What is the value of b at point B in the code above?
3. What is the output of the code above?
4. How many times is the statement i //= 5 executed in the code above? a. 10 b. 2 c. 5 d. None of the above.
2 | P a g e
CPSC111BV-Introduction to Computing: Fall 2019 Midterm Exam 2 – Muntaseer Salahuddin 5. What is the output of the following code? i = 1 while i < 100: if i%2 != 0: print(i) i -= 1
6. What type of an error exists in the following code? i = 1 while i < 100: if i%2 != 0: print(i) i -= 1
7. How many times is the print(“h”) statement executed in the following code? for i in range(5,1,2): print("h") if i > 4: print(i) i += 1