Question
Language: Python Topic: Files I/O assume that the .txt file will be formatted as follows: food name calories food_type $price food name calories food_type $price
Language: Python
Topic: Files I/O
assume that the .txt file will be formatted as follows:
food name calories food_type $price
food name calories food_type $price ...
There will be a line with the name of the food item followed by a line with the amount of calories, the type of food, and the price. The file may contain a variable number of empty lines between each food item
An example file could be formatted as follows:
Chicken Parm 710 Entree $17.50
gelato 100 dessert $4.00
Function name : split_bill Parameters : file (str), num_ppl (int), order (list), tip (float) Returns: float Description : Write a function which calculates how much each person in a group needs to pay for dinner. Your code should take into account the price of each food in the order list and then factor in the tip. The tip will be between 0 and 1 inclusive. A tip of 0.15, for example, represents a 15% tip. The total bill should be split evenly between num_ppl. Return how much each person should pay rounded to 2 decimal places. You can assume that num_ppl will be greater than 0.
Test Cases:
>>> split_bill('olive_garden.txt',2,['cheese Ravioli', 'tiramisu'],0.17) 11.28
>>> split_bill('olive_garden.txt',3,['DIP DUO','salmon','zeppoli','SMores layer CAKE'],0.20) 11.36
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started