FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Tools/demo/beer.py at master · python-emscripten/cpython · GitHub
python-emscripten
cpython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Tools
/
demo
/
beer.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
25 lines (19 loc) · 566 Bytes
Breadcrumbs
cpython
/
Tools
/
demo
/
beer.py
Copy path
File metadata and controls
executable file
·
25 lines (19 loc) · 566 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
"""
A Python version of the classic "bottles of beer on the wall" programming
example.
By Guido van Rossum, demystified after a version by Fredrik Lundh.
"""
import
sys
n
=
100
if
sys
.
argv
[
1
:]:
n
=
int
(
sys
.
argv
[
1
])
def
bottle
(
n
):
if
n
==
0
:
return
"no more bottles of beer"
if
n
==
1
:
return
"one bottle of beer"
return
str
(
n
)
+
" bottles of beer"
for
i
in
range
(
n
,
0
,
-
1
):
print
(
bottle
(
i
),
"on the wall,"
)
print
(
bottle
(
i
)
+
"."
)
print
(
"Take one down, pass it around,"
)
print
(
bottle
(
i
-
1
),
"on the wall."
)
Back
|
FazBrowse Home
|
New Git URL