Fizz-Buzz Program in Python
Fizz-Buzz is the programming task used for explaining the division of numbers in the Fizz, Buzz, and Fizz_Buzz group.
Suppose the user has the number 'n,' and they have to display the string representation of all the numbers from 1 to n. But there are some limitations such as:
For solving the above problem and considering the limitations, we have to follow the below steps:
In the program, we have to apply the condition for all the numbers from 1 to 'n.'
['1', '2', ' Fizz ', '4', ' Buzz ', ' Fizz ', '7', '8', ' Fizz ', ' Buzz ', '11', ' Fizz ', '13', '14', ' Fizz_Buzz ', '16', '17', ' Fizz ', '19', ' Buzz ', ' Fizz ', '22', '23', ' Fizz ', ' Buzz ', '26', ' Fizz ', '28', '29', ' Fizz_Buzz ', '31', '32', ' Fizz ', '34', ' Buzz ', ' Fizz ', '37', '38', ' Fizz ', ' Buzz ']
We can also write the above program by using the loop method.
Fizz_Buzz 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 Fizz_Buzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 Fizz_Buzz 31 32 Fizz 34
In this article, we have discussed how the user can write a python program for the Fizz Buzz problem, we have also discussed some limitations that must be followed.
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week