Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Datalog Engines In Databases

Authors: Bas Ketsman ,Paraschos Koutris

1st Edition

1638280428, 978-1638280422

More Books

Students also viewed these Databases questions

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago

Question

Describe the new structures for the HRM function. page 676

Answered: 1 week ago