From b9527bd6ec4c78a185c3bdebd85fce8de55c5c7e Mon Sep 17 00:00:00 2001 From: Ag-Utkarsh Date: Sun, 15 Oct 2023 16:09:37 +0530 Subject: [PATCH] feat: :art: FizzBuzz program in Python Added a new algorithm, Fizzbuzz it is a fun program to understand how for, if, range() works in Python --- python/maths/fizzbuzz.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 python/maths/fizzbuzz.py diff --git a/python/maths/fizzbuzz.py b/python/maths/fizzbuzz.py new file mode 100644 index 000000000..0ced07a44 --- /dev/null +++ b/python/maths/fizzbuzz.py @@ -0,0 +1,14 @@ +#Write a Python program that iterates the integers from 1 to 50. +# For multiples of three print "Fizz" instead of the number and for multiples of five print "Buzz". +# For numbers that are multiples of three and five, print "FizzBuzz". +for fizzbuzz in range(101): + if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0: + print("fizzbuzz") + continue + elif fizzbuzz % 3 == 0: + print("fizz") + continue + elif fizzbuzz % 5 == 0: + print("buzz") + continue + print(fizzbuzz) \ No newline at end of file