# break: stop the loopfor num in range(10): if num == 5: break print(num, end=" ") # 0 1 2 3 4# continue: skip the current iterationfor num in range(10): if num % 2 == 0: continue print(num, end=" ") # 1 3 5 7 9# for-else: else runs if loop completes without breakfor n in range(2, 10): for d in range(2, n): if n % d == 0: break else: print(f"{n} is a prime number")
Today’s Exercises
Write a program that prints multiplication tables from 2 to 9.
Print the first 20 terms of the Fibonacci sequence.
Keep accepting numbers from the user until they type “quit”, then print the total sum.