Python Forum
Bartender Tip out help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bartender Tip out help
#1
Hello, I'm trying to create a program that generates an hourly wage per person and their total tip out for the day. I really need help, I just work too much and I'm trying to get this program going to make my life a little easier so please, somebody help me. I need it to do this
Name of bartenders
Total Tip
Total hourly
Hours workers per bartender
Display the total amount of money per bartender along with they're hourly wage
This is what I have so far:


def main():
    name = []

    total_people = (int(input("Enter Total Number of Bartenders: ")))
    for x in range(total_people):
        print("Please enter the name of Bartender #",x+1)
        name_each = input("")
        name.append(name_each)
    print(name)
    total_amount = float(input("Enter total amount of tips:"))
    total_hours = float(input("Enter the total hours:"))

    hourly_wage = total_amount / total_hours
    print("Your hourly wage is: ",hourly_wage) 

    for y in range(name):
        print(y)
main()
Its 3am and I gotta work another double today. If somebody could help me please, I will appreciate it a lot
buran write Apr-13-2021, 09:23 AM:
Thread moved to Homework
buran write Apr-13-2021, 09:22 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
First you must read BBCode. It tells you how to post python code indented the right way. Python code without indentation is unreadable.

Second you must make a choice about your data model. Is it sufficient to have a user input all data and have the program print the values after the data of each bartender is complete? Then you need no data model.

But you are using a list to hold the names of the bartenders. Then you should also have structures to hold Total Tip,Total hourly and Hours worked per bartender. You may store these in three lists. Then you know you must use the index of the bartender and use that index to access the data of that bartender.

Or you can create a dictonary where the keys are the names of the bartenders and the value of the data of each bartender could then be a list. For example:
bartender["peter"] = [total_tip, total_hourly, hours_worked]
Or you can create a dictonary where the keys are the names of the bartenders and the value is a dictionary containing the data. The last mentioned dictionary should have three keys: "total_tip", "total_hourly", "hours_worked". For example:
bartender["peter"]["total_tip"] = 2.50
Reply
#3
(Apr-13-2021, 08:57 AM)ibreeden Wrote: First you must read BBCode. It tells you how to post python code indented the right way. Python code without indentation is unreadable.

Second you must make a choice about your data model. Is it sufficient to have a user input all data and have the program print the values after the data of each bartender is complete? Then you need no data model.

But you are using a list to hold the names of the bartenders. Then you should also have structures to hold Total Tip,Total hourly and Hours worked per bartender. You may store these in three lists. Then you know you must use the index of the bartender and use that index to access the data of that bartender.

Or you can create a dictonary where the keys are the names of the bartenders and the value of the data of each bartender could then be a list. For example:
bartender["peter"] = [total_tip, total_hourly, hours_worked]
Or you can create a dictonary where the keys are the names of the bartenders and the value is a dictionary containing the data. The last mentioned dictionary should have three keys: "total_tip", "total_hourly", "hours_worked". For example:
bartender["peter"]["total_tip"] = 2.50



Thanks, I am super lost because haven't touch this program in forever lol
Reply
#4
Ah now that it is formatted I can see what your program does.
It already looks quite nice. It would work when you would indent lines 9 to 14 so they would be included in the "for" loop.
But then adding the names to the "name" list is not useful anymore. Neither are lines 16 and 17.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020