Question: OBJECTIVE You will practice how to read numerical and text data from the command line, do simple arithmetic computations, and to output results to the

OBJECTIVE

You will practice how to read numerical and text data from the command line, do simple arithmetic computations, and to output results to the terminal, but this time using lists to store the data.

THE PROBLEM

You have been in a fancy restaurant with four of your best friends. All the individual bills are brought to the table and it is time to add the tip and to compute everyone's share. Since nobody ordered anything extravagantly expensive, you decide that everyone will pay an equal share of the bill.

The number of friends variable "number_of_friends" is already provided for you as function parameter and initialized with a default value of 5. Inside your program, you have to declare2 newvariables: onefor a list ofnames andfor a list ofbills.Assume the group has five or more people.Request names of the attendees and store them inthe list'names'. Then assign bills for each person and store each of them in the corresponding list variable'bills'.Print out both ofthose variables. Next ask for input for the tip percentage and compute and print the total bill and the amount each person must pay.

You aremustuse the number_of_friends variable in defining the number of iterations for yourloop (either for or while loop)and the size or length of your lists must match the value ofnumber_of_friends.All variables must be declared except (number_of_friends)and used.You willget a ZEROif younot comply with the instructions.

Your program should start by a documentation string that includes your name, the program name, the Course number, the semester and a short description of the program, as in:

"""Tanvir Rahman, Peoplesoft ID: 111111

Program #1: Sharing the bill

211 Python, Spring 20..

This program computes individual shares of a restaurant bill. """

Note that the text above starts and ends with three double quotes.

HINTS

1. The easiest way to output numbers with two decimals is to use the f-stringsto insert them into a

string:

print(f"The result is{result:.2f }")

Output:The following example demonstrates the expected output from running your program.

Enter name of friend: David

Enter name of friend: John

Note that these names and bills must be entered by the user from the keyboard and not hard coded in your program.

Enter name of friend: JaneEnter name of friend: Smith

Enter name of friend: Ali

Enter bill for David: 25.2

Enter bill for John: 22.99

Enter bill for Jane: 23.5

Enter bill for Smith: 24.0

Enter bill for Ali: 24.8

Names of Friends: David, John, Jane, Smith, Ali

Individual bills: 25.2, 22.99, 23.5, 24.0, 24.8

Enter tip percentage: 20

Total bill plus tip: $ 144.59

Each of us must pay $ 28.92

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!