/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FizzBuzz.py
22 строки
639 B
NIKITA PANDEY
Update FizzBuzz.py
17 мар 2023, 12:38
Не верифицирован
17 мар 2023, 12:38
12b4866
Код
Авторство
О чём код?
# FizzBuzz # A program that prints the numbers from 1 to num (User given number)! # For multiples of ‘3’ print “Fizz” instead of the number. # For the multiples of ‘5’ print “Buzz”. # If the number is divisible by both 3 and 5 then print "FizzBuzz". # If none of the given conditions are true then just print the number! def FizzBuzz(num): for i in range(1, num + 1): if i % 3 == 0 and i % 5 == 0: print("FizzBuzz") elif i % 3 == 0: print("Fizz") elif i % 5 == 0: print("Buzz") else: print(i) FizzBuzz(20) # prints FizzBuzz up to 20