151k views
3 votes
Write a split_check function that returns the amount that each diner must pay to cover the cost of the meal. The function has 4 parameters: bill: The amount of the bill. people: The number of diners to split the bill between. tax_percentage: The extra tax percentage to add to the bill. tip_percentage: The extra tip percentage to add to the bill.

1 Answer

5 votes

Answer:

def split_check(bill, people, tax_percentage, tip_percentage):

tax = bill * tax_percentage

tip = bill * tip_percentage

total_bill = bill + tax + tip

return total_bill / people

Step-by-step explanation:

Create a function called split_check that takes four parameters, bill, people, tax_percentage, and tip_percentage

Inside the function, calculate the tax, multiply bill by tax_percentage. Calculate the tip, multiply bill by tip_percentage. Calculate the total_bill, sum bill, tax, and tip. Finally, return the total_bill / people which gives the amount each diner needs to pay.

User SaintTail
by
6.2k points