종래 방법 | 권고 방법 |
food_item = input("Enter Food Item Name: ") def getPrice(food_item): if food_item == "Burger": return 100 elif food_item == "Pizza": return 200 elif food_item == "Juice": return 50 elif food_item == "Apple": return 150 print(getPrice(food_item)) |
food_item = input("Enter Food Item Name: ") food_items = { "Burger":100 "Pizza":200 "Juice": 50 "Apple":150 } def getPrice(food_item): return food_items.get(food_item, 0) print(getPrice(food_item)) |
'data science > python' 카테고리의 다른 글
Dijkstra Algorithm가 구현된 osmnx 라이브러리를 이용한 경로 검색 (0) | 2025.02.22 |
---|---|
Dijkstra Algorithm (Google map 에서도 사용하는 경로 찾기) (0) | 2025.02.21 |
(colab) web scrapping (0) | 2025.02.16 |
dict 을 이용한 일괄 문자열 바꿔치기 (0) | 2025.02.12 |
여러 단어를 한 단어로 바꿔치기 (1) | 2025.02.11 |