82.1k views
4 votes
Task

Ask for the total price of the bill, then ask how many diners there are. Divide the total bill by the number of diners and show how much each person must pay.
I need code for this on Repl.it python

User Loko
by
4.4k points

2 Answers

5 votes

Answer:

Please see the full code in explanation

Step-by-step explanation:

#This is a console program

def bill_calculator():

print("Enter the Total value of the bill:\\")

bill_total = float(input())

print("Enter total number of dinners:\\")

total_dinner = int(input())

bill_per_person = bill_total / total_dinner

result = ("Bill total: {} \\"

"Total dinners: {} \\"

"Bill per person: {} ").format(bill_total,total_dinner, bill_per_person)

print(result)

if __name__ == '__main__':

bill_calculator()

User Kamil Jopek
by
5.5k points
7 votes

When you run the script, it will prompt you to enter the total bill amount and the number of diners. Below is a simple Python script for the requirement.

# Get the total bill amount from the user

total_bill = float(input("Enter the total bill amount: $"))

# Get the number of diners

num_diners = int(input("Enter the number of diners: "))

# Calculate the amount each person must pay

amount_per_person = total_bill / num_diners

# Display the result

print(f"\\Each person must pay: ${amount_per_person:.2f}")

User Oleg Pryadko
by
4.9k points