IDE는 통합 개발 환경이다. 우리의 코드를 작성 효율을 높여준다
우리가 사용할 IDE는 파이썬에 특화된 파이참이다.
파이참을 설치하기 전에 최신버전의 파이썬을 설치해야 한다.

저거 눌러서 확인 눌러주고 Close로 닫으면 된다.
파이참_다운로드
Community 버전을 다운로드 하면 된다.
새로운 프로젝트를 만들 때, 최신버전의 파이썬과 연결해야 한다.

적당한 코드를 입력하여 잘 실행되는지 확인한다.

에스프레소, 라떼, 카푸치노를 만든다.
- 에스프레소는 50ml물, 18g 커피가 들어간다. 가격:1.5달러
- 라떼는 200ml물, 24g커피, 150ml우유가 들어간다. 가격:2.5달러
- 카푸치노는 250ml물, 24g커피, 100ml우유가 들어간다. 가격:3달러
- 커피머신 시작에는, 300ml물, 100g커피, 200ml우유를 채워야 한다.
- 동전을 넣어서 작동시킨다.
- 들어갈 수 있는 동전은 Penny(1cent), Nickel(5cents), Dime(10cents), Quarter(25cents)가 있다.
프로그램 요구 사항
- report를 입력하면, 재료가 얼마나 남았고 돈이 얼마나 있는지 확인 가능하다.
- 재료가 충분한지, 잔돈을 거슬러 줄 동전이 충분한지 확인이 가능해야 한다. (Check resources sufficient)
- 반드시 코인을 넣어야 한다.
- 커피 가격을 기준으로, 동전을 거슬러 줘야 한다.
- 동전을 충분히 넣지 않았다면, 동전을 반환해주고 커피를 만들어 주지 않는다.
- 동전을 충분히 넣었다면, 동전을 거슬러주며 커피를 만들어준다.
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,
}
}
profit = 0
resources = {
"water": 300,
"milk": 200,
"coffee": 100,
}
def is_resource_sufficient(order_ingredients):
"""Returns True when order can be made, False if ingredients are insufficient."""
for item in order_ingredients:
if order_ingredients[item] > resources[item]:
print(f"Sorry there is not enough {item}.")
return False
return True
def process_coins():
"""Returns the total calculated from coins inserted."""
print("Please insert coins.")
total = int(input("how many quarters?: ")) * 0.25
total += int(input("how many dimes?: ")) * 0.1
total += int(input("how many nickles?: ")) * 0.05
total += int(input("how many pennies?: ")) * 0.01
return total
def is_transaction_successful(money_received, drink_cost):
"""Return True when the payment is accepted, or False if money is insufficient."""
if money_received >= drink_cost:
change = round(money_received - drink_cost, 2)
print(f"Here is ${change} in change.")
global profit
profit += drink_cost
return True
else:
print("Sorry that's not enough money. Money refunded.")
return False
def make_coffee(drink_name, order_ingredients):
"""Deduct the required ingredients from the resources."""
for item in order_ingredients:
resources[item] -= order_ingredients[item]
print(f"Here is your {drink_name} ☕️. Enjoy!")
is_on = True
while is_on:
choice = input("What would you like? (espresso/latte/cappuccino): ")
if choice == "off":
is_on = False
elif choice == "report":
print(f"Water: {resources['water']}ml")
print(f"Milk: {resources['milk']}ml")
print(f"Coffee: {resources['coffee']}g")
print(f"Money: ${profit}")
else:
drink = MENU[choice]
if is_resource_sufficient(drink["ingredients"]):
payment = process_coins()
if is_transaction_successful(payment, drink["cost"]):
make_coffee(choice, drink["ingredients"])