🔒 Closed Help Phyton programming

Status
Not open for further replies.
A babysitter charges $2.50 an hour until 9:00 PM, when the rate drops to $1.75 an hour (the children are in bed). Write a program that accepts a starting time and ending time in hours and minutes and calculates the total babysitting bill. You may assume that the starting and ending times are in a single 24-hour period. Partial hours should be appropriately prorated.
 
Well, you should at least give some effort. Because it's your assignment.
Next time post karin muna ng panimula mong code then we will fix kung anong error or kung anong question mo.


Python:
def split_time(t: str, i: int):
    return float(t.split(':')[i])

def calculate_time(eh: float, em: float, sh: float, sm: float):
    return (eh + em / 60) - (sh + sm / 60)

def calculate_payment(startTime, endTime):
    start_hour = split_time(startTime, 0)
    start_mins = split_time(startTime, 1)
    end_hour = split_time(endTime, 0)
    end_mins = split_time(endTime, 1)
    time = calculate_time(end_hour, end_mins, start_hour, start_mins)
   
    payment_costs = 2.5 * time
   #Try first to calulate the payment kung di mo na talaga kaya, add ko yung calculation


def main():
    print("Note: Enter military time only")
    start = input("Enter starting time: ")
    end = input("Enter ending time: ")

    print(calculate_payment(start, end))

if __name__ == "__main__":
    main()
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 824
    Views
  • 2
    Participants
Last reply from:
zackmark29

Trending Topics

Online now

Members online
388
Guests online
3,969
Total visitors
4,357

Forum statistics

Threads
2,338,263
Posts
29,303,053
Members
1,126,159
Latest member
heepmlh
Back
Top