Python Forum
Hello all! need help. calculating OT hours.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello all! need help. calculating OT hours.
#1
So, I'm "self teaching" python, and I'm trying to challenge myself. I'll take the answer but a "hint" would be more helpful in the long run. So, I'm making a simple pay calculator program. I have some simple code, but I don't know how to add the "OT = over time" hours in. I'd like to calculate anything over 40 hours gets time and a half. so the following is my code.

rate = 10
ot_rate = 15
time = input("please enter your time: ")
time_int= int(time)
pay = int(rate) * int(time)

if time_int > 40:
    
    print(f" Your pay is ${}")
else:
    print(f" Your pay is ${pay}")
Larz60+ write Jul-30-2022, 10:06 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed for you this time. Please use bbcode tags on future posts.
Reply


Messages In This Thread
Hello all! need help. calculating OT hours. - by no1up - Jul-30-2022, 03:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  MatplotibTicks every 24 hours TamP 4 1,198 Oct-04-2022, 04:08 PM
Last Post: deanhystad
  Py script that triggers ever 3 hours, but only between 9:15 am to 3:30 pm, Mon to Fri Pymod 2 1,864 Jun-30-2021, 05:14 PM
Last Post: Larz60+
  How to get utcnow + 2 hours? korenron 2 2,586 Mar-01-2021, 03:22 PM
Last Post: korenron
  Need to add hours min and seconds tester_V 5 3,146 Jun-02-2020, 05:29 PM
Last Post: tester_V

Forum Jump:

User Panel Messages

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