[Python #7] create e37.py
This commit is contained in:
parent
f7e0d8cb08
commit
3be335b9cc
3 changed files with 29 additions and 3 deletions
26
kjg/python-the-hard-way/e37.py
Normal file
26
kjg/python-the-hard-way/e37.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
while 1:
|
||||||
|
money = input("insert coin=>")
|
||||||
|
number = input("select beverage\n")
|
||||||
|
money = int(money)
|
||||||
|
temp = money
|
||||||
|
if number == "1":
|
||||||
|
#grape 100
|
||||||
|
print("you choose grape. change is ",money-100,"coin")
|
||||||
|
money = temp-100 #callculate change
|
||||||
|
if money <= 0: #check money
|
||||||
|
break
|
||||||
|
elif number == "2":
|
||||||
|
#orange 200
|
||||||
|
print("you choose orange. change is ",money-200,"coin")
|
||||||
|
money = temp-200 #callculate change
|
||||||
|
if money <= 0: #check money
|
||||||
|
break
|
||||||
|
elif number == "3":
|
||||||
|
#fanta 300
|
||||||
|
print("you choose fanta. change is ",money-300,"coin")
|
||||||
|
money = temp-300 #callculate change
|
||||||
|
if money <= 0: #check money
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
#wrong sellection
|
||||||
|
print("wrong number. please select again")
|
|
@ -1,3 +0,0 @@
|
||||||
23+45+23+4+1+54=150
|
|
||||||
2+3+4+6+7+8=30
|
|
||||||
9+8+7+7+8+0=39
|
|
|
@ -135,3 +135,6 @@ practice function, while, if
|
||||||
some rules of if, loop and tips for debugging
|
some rules of if, loop and tips for debugging
|
||||||
*** Python applying learnings from 1..6
|
*** Python applying learnings from 1..6
|
||||||
create calc.py
|
create calc.py
|
||||||
|
*** Python #7
|
||||||
|
**** ex37
|
||||||
|
analysis sample codes
|
||||||
|
|
Loading…
Reference in a new issue