진심 쉽게만 살아가고 싶다 ...
내가 듣는 파이썬 강의 쉽게 따라가기 좋다
☕️ 강의
https://www.udemy.com/course/100-days-of-code/
☕️ main.py
import menu
def resource_suff(order) :
"""재료 충분한지 췤!"""
for item in order :
if order[item] >= menu.resources[item] :
print(f"미앙 {item} (이)가 없슴다 ")
return False
return True
def process_coin() :
"""총 금액 췤!"""
print("동전을 투입하시오 : ")
total = int(input("쿼터 몇개 ? :")) * 0.25
total += int(input("다임 몇개 ? :")) * 0.1
total += int(input("니켈 몇개 ? :")) * 0.05
total += int(input("페니 몇개 ? :")) * 0.01
return total
def money_check(insert_c, cost) :
if insert_c >= cost :
change = round(insert_c - cost)
print(f"잔돈 : {change}")
return True
else :
print("잔액 부족 ")
return False
def make_coffee(dr, ing) :
"""재료 차감 쳌!"""
for item in ing :
menu.resources[item] -= ing[item]
print(f"주문하신 {dr} 나왔습니다 - ! ")
def coffee_dsil() :
coffee_continue = True
while coffee_continue :
drink = input("뭐 드실 ?(espresso/latte/cappuccino) : ")
if drink == "off" :
coffee_continue = False
elif drink == "report" :
print(f"water : {menu.resources['water']}")
print(f"milk : {menu.resources['milk']}")
print(f"coffee : {menu.resources['coffee']}")
else :
chosen = menu.MENU[drink]
if resource_suff(chosen["ingredients"]) :
money = process_coin()
if money_check(money, menu.MENU[drink]["cost"]) :
make_coffee(drink, chosen["ingredients"])
coffee_dsil()
☕️ menu.py
MENU = {
"espresso": {
"ingredients": {
"water": 50,
"coffee": 18,
},
"cost": 1.5,
},
"latte": {
"ingredients": {
"water": 200,
"milk": 150,
"coffee": 24,
},
"cost": 2.5,
},
"cappuccino": {
"ingredients": {
"water": 250,
"milk": 100,
"coffee": 24,
},
"cost": 3.0,
}
}
resources = {
"water": 300,
"milk": 200,
"coffee": 100,
}
☕️ 실행 결과

'Python 🎧' 카테고리의 다른 글
| [python] turtle 모듈 예제 - n각형/점선/랜덤컬러/스피로그래프 (2) | 2024.08.18 |
|---|---|
| [python] 클래스 - 생성/속성/메소드/초기화 (2) | 2024.08.16 |
| [python] up&down/higher&lower 게임 - 리스트/배열 (0) | 2024.08.12 |
| [python] 전역/지역 변수 - namespace (2) | 2024.08.12 |
| [python] 출력과 함수 - 윤년반영 월별 일수 계산/docstrings/딕셔너리 함수 결합/계산기/재귀함수 (0) | 2024.08.12 |