8 what is the output of the following code x 100

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

This preview shows page 3 - 6 out of 6 pages.

8. What is the output of the following code? x = 100 while True: if x < 20: break x-=19 print(x) a. 19 b. 5 c. 1 d. None of the above
9. How many times is the print(“h”) statement executed in the following code? for x in "accgtttta": if x == "t": continue print("h")
10. How many times is the print(“h”) statement executed in the following code? for x in "accgtttta": if x in "gta": continue print("h")
3 | P a g e
CPSC111BV-Introduction to Computing: Fall 2019 Midterm Exam 2 – Muntaseer Salahuddin 11. [10 points] Write down the output of the following Python statements in case of no output please state as such. If a statement results in an error, write ‘error’ and explain briefly what error it is. Python statements Outputs
4 | P a g e
CPSC111BV-Introduction to Computing: Fall 2019 Midterm Exam 2 – Muntaseer Salahuddin 12. [20 points] Programming Questions a) [8 points] Write a pseudocode for the following problem.
5 | P a g e 1. Read number 2. If IsAbundant(number) returns true do step 2.a a. Write “abundant” 3. Else do step 3.a a. Write “not abundant” 1. IsAbundant(num) a. divisor = 1 b. sum = 0 c.
• • • 