File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ We will use this script to teach Python to absolute beginners
3
+ The script is an example of Fizz-Buzz implemented in Python
4
+
5
+ The FizzBuzz problem:
6
+ For all integers between 1 and 99 (include both):
7
+ # print fizz for multiples of 3
8
+ # print buzz for multiples of 5
9
+ # print fizzbuzz for multiples of 3 and 5"
10
+ """
11
+
12
+ def fizzbuzz (max_num ):
13
+ "This method implements FizzBuzz"
14
+ # Google for 'range in python' to see what it does
15
+ for i in range (1 ,max_num ):
16
+ # % or modulo division gives you the remainder
17
+ if i % 3 == 0 and i % 5 == 0 :
18
+ print (i ,"fizzbuzz" )
19
+ elif i % 3 == 0 :
20
+ print (i ,"fizz" )
21
+ elif i % 5 == 0 :
22
+ print (i ,"Buzz" )
23
+
24
+ #----START OF SCRIPT
25
+ if __name__ == '__main__' :
26
+ fizzbuzz ('16' )
You can’t perform that action at this time.
0 commit comments