1. Iteration refers to the use of __________ in programming
2. There are three main types of loops. Which of the following is NOT a type of loop
3. A loop, by definition, is getting code to ___________ itself and every loop needs a __________ condition.
4. A while loop is different from a repeat…until loop in that …
5. In a language like VB.Net a while loop must end with an 'End While' statement, and it is the same in python
6. Analyse the following code - what will the output be?
def main():
i=0
while i<10:
print(i)
main()
0
1,2,3,4,5,6,7,8,9,10
0,1,2,3
An infinite loops of 0s (zeros)
7. Analyse the code below and see if you can fix the loop to produce an output of 0.1.2,3,4,5,6,7,8,9
def main():
i=0 #this is the value of i to start with (initial value)
while i<10: #this is the condition of the loop
#i will be printed because the condition is true
print(i)#i is still 0, and it will be printed forever!
#What can we add here to make it print 0,1,2,3,4,5,6,7,8,9?
main()
replace the last comment with i+0 (this will add 0 to the value of i)
simple replace the last comment with i=i+1 (this will increase the value of i until it reaches 10)
None of the above
replace the last comment with i+9 (this will add 9 to the value of i)
8. The following while loop produces an output of 2,4,6,8. How can you make it go up to 10?
9. Which of the following options produces an output of 10,9,8,7,6,5,4,3,2,1
10. Run the following code, or trace its logic. Why will it never accept the password 'open123'?
11. What is happening in the following program? Which statement describes it best?
12. What change needs to be done to the following code to make the output just '5'
13. The use of a while loop in a program means that …
14. How could a while loop be used in game design? Which statement is correct?
15. A while loop is different from a 'for' loop in that ….