Guest User

Untitled

a guest
Feb 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. """
  2. Write a program that prints the numbers from 1 to 100.
  3. But for multiples of three print “Fizz” instead of the
  4. number and for the multiples of five print “Buzz”. For
  5. numbers which are multiples of both three and five print
  6. “FizzBuzz”.
  7. """
  8.  
  9. def fizz_buzz(max_num):
  10. for num in range(1, max_num + 1):
  11. if num % 3 == 0 and num % 5 == 0:
  12. print('FizzBuzz')
  13. elif num % 5 == 0:
  14. print('Buzz')
  15. elif num % 3 == 0:
  16. print('Fizz')
  17. else:
  18. print(num)
  19.  
  20.  
  21. fizz_buzz(100)
Add Comment
Please, Sign In to add comment