Question

In: Computer Science

In PYTHON 3 using functions. Per the client, you have the following information:  customer name, burger choice,...

In PYTHON 3 using functions. Per the client, you have the following information:  customer name, burger choice, time of purchase, and total bill. By the end of the day, your program will provide the following information:

1. Top three best clients with the highest spending

2. Name of client with second to last lowest bill

3. busiest hour of the day based on number of clients

Assumptions

1. Your program will not handle more than 100 clients per day

2. The restaurant only has six types of burgers

3. The restaurant works from 10:00 am until 10:00 pm

Solutions

Expert Solution

Python Code pasted below.

#Function definition
def top3Spenders(client_list):
#sort on total_bill to get the highest spender
client_list.sort()
#printing top three spenders
print("Top three best clients")
print("Name:",client_list[-1][1]," and highest spending: ",client_list[-1][0])
print("Name:",client_list[-2][1]," and highest spending: ",client_list[-2][0])
print("Name:",client_list[-3][1]," and highest spending: ",client_list[-3][0])
def secondLowestBill(client_list):
#printing name of the client with second to last lowest bill
print("Name of the client with second last lowest bill:",client_list[1][1]," and the bill amount: ",client_list[1][0])
def busyHour(client_list):
#initializing an empty dictionary to store the time and its count
dict={}
for item in client_list:
#Item is a tuple. In the tuple last one is the time. Hence index is -1
if item[-1] not in dict:
dict[item[-1]]=1
else:
dict[item[-1]]+=1
#sorting the dictionary in descending order of the values
sort_dict=sorted(dict.items(),key=lambda x:x[1],reverse=True)
print("Busiest hour:",sort_dict[0][0])
#main program
#Reading customer details
n=int(input("Enter how many customers?(<=100) "))
#initializing empty list
client_list=[]
#reading the details of n customers
for i in range(0,n):
name=input("Enter the customer name:")
burger=input("Enter burger choice from this list(A,B,C,D,E,F):")
time_of_purchase=input("Enter the time(10.00 am to 10.00 pm):")
total_bill=float(input("Enter the total bill amount:"))
#adding all the details as tuple to the list named client_list
client_list.append((total_bill,name,burger,time_of_purchase))
#Function call
top3Spenders(client_list)
secondLowestBill(client_list)
busyHour(client_list)

Python code in IDLE pasted for better understanding of the indent.

Output Screen


Related Solutions

Solve using PYTHON 3 and use functions. You have been hired by a restaurant named "Burger...
Solve using PYTHON 3 and use functions. You have been hired by a restaurant named "Burger Shack" Per the client, you have the following information: the client’s name, burger’s name, time of the day, and the total bill. By the end of the day, your program will provide the following information: 1. Top three best clients (highest bills) 2. Name of the client with the second-to-last lowest bill 3. Busiest hour of the day (number of clients) Assumptions: 1. doesn't...
In Python Create customer information system as follows: Python 3 Create customer information system as follows:...
In Python Create customer information system as follows: Python 3 Create customer information system as follows: Ask the user to enter name, phonenumber, email for each customer. Build a dictionary of dictionaries to hold 10 customers with each customer having a unique customer id. (random number generated) Take the keys of the above mentioned dictionary which are customer ids and make a list. Ask the use to enter a customer id and do a binary search to find if the...
Python 3 Forming Functions Define and complete the functions described below. * function name: say_hi *...
Python 3 Forming Functions Define and complete the functions described below. * function name: say_hi * parameters: none * returns: N/A * operation: just say "hi" when called. * expected output: >>> say_hi() hi * function name: personal_hi * parameters: name (string) * returns: N/A * operation: Similar to say_hi, but you should include the name argument in the greeting. * expected output: >>> personal_hi("Samantha") Hi, Samantha * function name: introduce * parameters: name1 (string) name2 (string) * returns: N/A...
Python 3 Functions that give answers Define and complete the functions described below. * function name:...
Python 3 Functions that give answers Define and complete the functions described below. * function name: get_name * parameters: none * returns: string * operation: Here, I just want you to return YOUR name. * expected output: JUST RETURNS THE NAME...TO VIEW IT YOU CAN PRINT IT AS BELOW >>> print(get_name()) John * function name: get_full_name * parameters: fname (string) lname (string) first_last (boolean) * returns: string * operation: Return (again, NOT print) the full name based on the first...
Challenges Using Python 3. Write a program that displays the name of a card randomly chosen...
Challenges Using Python 3. Write a program that displays the name of a card randomly chosen from a complete deck of 52 playing cards. Each card consists of a rank (Ace. 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) and a suit (Clubs, Diamonds, Hearts. Spades).
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and use a function named highest() that takes three inputs and returns the highest number. After you have got it working, try calling the function with inputs ‘hat’, ‘cat’, ‘rat’.
Using python Write a program that has 3 functions, named write_to_file, read_from_file, and ask_user. The write_to_file...
Using python Write a program that has 3 functions, named write_to_file, read_from_file, and ask_user. The write_to_file function should have 2 parameters, file_name and data. When called, the function will open a file with the name stored in the file_name variable, write the information stored in data, then close the file. The read_from_file function will have 1 parameter, file_name. When called, the function will open a file with the name stored in the file_name variable, print the contents of the file,...
Using a Python environment of your choice – Create the following three dictionaries: Gary, Alice, and...
Using a Python environment of your choice – Create the following three dictionaries: Gary, Alice, and Tyler Gary = { "name": "Gary", "homework": [90.0,97.0,75.0,92.0], "quizzes": [88.0,40.0,94.0], "tests": [75.0,90.0] } Alice = { "name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.0, 97.0] } Tyler = { "name": "Tyler", "homework": [0.0, 87.0, 75.0, 22.0], "quizzes": [0.0, 75.0, 78.0], "tests": [100.0, 100.0] } Insert one additional (new) dictionary of your choice Create a new list named students that...
Using a Python environment of your choice – Create the following three dictionaries: Gary, Alice, and...
Using a Python environment of your choice – Create the following three dictionaries: Gary, Alice, and Tyler Gary = { "name": "Gary", "homework": [90.0,97.0,75.0,92.0], "quizzes": [88.0,40.0,94.0], "tests": [75.0,90.0] } Alice = { "name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.0, 97.0] } Tyler = { "name": "Tyler", "homework": [0.0, 87.0, 75.0, 22.0], "quizzes": [0.0, 75.0, 78.0], "tests": [100.0, 100.0] } Insert one additional (new) dictionary of your choice Create a new list named students that...
Code in python the grocery receipt the following steps using the knowledge you have. declare a...
Code in python the grocery receipt the following steps using the knowledge you have. declare a string variable called card_number. Assign a value of “xxx8974” declare a string variable called date and assign a string value of “9\7\2020” You need to use an escape sequence for the slashes in this string. See Mosh’s video 2.4-Escape Sequence if needed. You do not need to use a date class variable as we have not learned that data type yet. Use a simple...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT