Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the FizzBuzz problem by python

Shulou Source: shulou.com Published: 2022-06-01 05:54:51 10月01日 Update

Editor to share with you python how to solve the FizzBuzz problem, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

60 characters solve FizzBuzz

Some time ago, Jeff Atwood promoted a simple programming exercise called FizzBuzz. The following questions are cited:

Write a program that prints a multiple of 1 to 100 Fizz 3 to replace this number, a multiple of 5 prints "Buzz", and a number that is both a multiple of 3 and a multiple of 5 prints "FizzBuzz".

Here is a short way to solve this problem:

For x in range (101x): print "fizz" [x% 3164fizz:] + "buzz" [x% 54th buzz:] or x is all the content of this article "how to solve the FizzBuzz problem by python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Questions multiples articles content numbers short not so much again most characters methods both time more knowledge procedures industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL vpn Linux Apple