✍️ While Loops
Level 1
Counter
Print the numbers 1 through 5 using a while loop.
NoteHint
Use a variable to keep track of how many times you’ve printed so far.
TipSolution
Growing up
Use a while loop to add progressively bigger numbers together until the sum reaches or exceeds 30. Start with number 1.
i.e. add 1 + 2 + 3 + 4 + … until the sum is 30 or larger
Bonus: at the end of the code, print the actual equation and result like:
1 + 2 + 3 = 6
NoteHint
You’ll need more than 1 variable for this one.
NoteHint for bonus
You can keep adding things to a string like:
my_name = my_name + " Bond"or, using an f-string:
my_name = f"{my_name} Bond"
TipSolution without bonus
TipSolution with bonus