Discussion
Questions
on Algorithms and Python programs
due: discussion time on Friday
1. What is the output of the following
algorithm?
1. Set num to 6.
2. Repeat while num > 0:
2a. print num
2b. set x to 3*num
2c. print x
2d. set num to num-1
2. What is the output of the following algorithm?
1. Set sum to 0.
2. Read an integer x from the user.
3. Repeat while x >= 0:
3a. Set sum to sum + x.
3b. Set x to x-1.
4. print sum.