Fizz Buzz in Python

Today's achievement.

Python


MAX = 100

i = 1
while i <= MAX:
  result = ""
  if i % 3 == 0:
    result += "fizz"
  if i % 5 == 0:
    result += "buzz"
  if result == "":
    result = i
  print result
  i += 1

Postscript

I remembered the for statement.

Python


MAX = 100

for i in range(1, MAX+1):
  result = ""
  if i % 3 == 0:
    result += "Fizz"
  if i % 5 == 0:
    result += "Buzz"
  if result == "":
    result = str(i)
  print result

Recommended Posts

Fizz Buzz in Python
Fizz Buzz in Python
Let's try Fizz Buzz in Python
I wrote Fizz Buzz in Python
Fizz Buzz
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Solve Fizz Buzz (equivalent to paiza rank C) in Python
Flatten in python
flatten in python
Daily AtCoder # 36 in Python
Clustering text in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Edit fonts in Python
Singleton pattern in Python
Challenge Fizz Buzz! Problems with Python in 5 patterns (only now up to 398)
File operations in Python
Read DXF in python
Daily AtCoder # 53 in Python
Key input in Python
Use config.ini in Python