Jan-07-2019, 08:39 AM
I will try
Python for Everybody 3.1 assignment
|
Jan-07-2019, 08:39 AM
I will try
Jan-07-2019, 12:12 PM
Yes sorry micseydel is right, I overread that part. rate should be an input as well
The correct code is: hours = float(input("Enter hours: ")) rate = float(input("Enter rate per hour: ")) ratePlus = rate * 1.5 if hours > 40: pay = 40 * rate + (hours - 40) * ratePlus else: pay = hours * rate print (pay)
Jan-07-2019, 02:22 PM
(This post was last modified: Jan-07-2019, 02:28 PM by ramadan2099.)
(Jan-07-2019, 12:12 PM)Mr_W Wrote: Yes sorry micseydel is right, I overread that part. rate should be an input as well thank you my friend It worked (Jan-07-2019, 02:22 PM)ramadan2099 Wrote:(Jan-07-2019, 12:12 PM)Mr_W Wrote: Yes sorry micseydel is right, I overread that part. rate should be an input as well whats wrong in my code here [Image: 284945816.png]
Jan-07-2019, 06:14 PM
ramadan2099: it sounds like that's a different question, please start a new thread. Also, as I've said more than once, stop posting screenshots, start using code tags, start providing errors (are you getting a syntax error? it looks like it).
Jan-07-2019, 07:31 PM
(Jan-07-2019, 06:14 PM)micseydel Wrote: ramadan2099: it sounds like that's a different question, please start a new thread. Also, as I've said more than once, stop posting screenshots, start using code tags, start providing errors (are you getting a syntax error? it looks like it). I am sorry thanks
Apr-27-2020, 05:43 PM
Hello all
I see that a working codehas already been posted but I'm trying to resist just copying somebody else's work. However, I'm getting a headache staring at this now! I'm a total beginner, admittedly but it's frustrating me that I'm getting stumped so early on in this course. With the below code, I'm not getting any errors, it's a perfectly good, working code. The issue is that I should be able to input: Hours 45 (sth) Rate 10.50 (str) ...and come out with an answer of 498.75 My code is coming up with 551.25 ! I'm sure it's something really simply that I'm overlooking because I've been staring for too long but can anyone spot it? sth = input("Enter hours: ") str = input("Enter rate: ") flh = float(sth) flr = float(str) if flh > 40 : reg = flr * flh ot = (flh - 40.0) * (flr * 1.5) pay = reg + ot else: pay = flh * flr print (pay)
Apr-27-2020, 06:57 PM
(This post was last modified: Apr-27-2020, 07:01 PM by deanhystad.)
You are paying 2.5 times for overtime.
if hours > 40: pay = hours * rate # paid for overtime at regular rate overtime = (hours -40) * rate * 1.5 # and more pay for overtime at 1.5 * rateThis is not a programming error and has nothing to do with python. This is a logic error. I think you are too worried about how to solve your problem in python when you should instead be focusing on how to solve the problem and then implementing your solution in python. You are not alone. I fall into the same trap at times and when I eventually step away from the computer and look at what I was doing I am appalled. The most important lesson I could teach you is that programming is a multi-part task. The first, and most important element is design, and that should occur away from the computer.
Apr-27-2020, 08:01 PM
(Apr-27-2020, 06:57 PM)deanhystad Wrote: You are paying 2.5 times for overtime. I thought as much! Thank you. Appreciate the tips as well, I’ll bear them in mind.
Jan-23-2021, 06:27 AM
use
print('pay=') print(pay) |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Python for Everybody 5.2 assignment | baba04201 | 20 | 183,675 |
Jul-25-2023, 04:15 PM Last Post: MicaelSchutz |
|
Coursera python for everybody 5.2 assignment | SteppentigerV2 | 11 | 15,457 |
Oct-22-2020, 11:57 AM Last Post: Larz60+ |
|
[split] Python for Everybody 5.2 assignment | ramadan2099 | 3 | 13,107 |
Jul-15-2020, 04:54 PM Last Post: Bipasha |
|
Python Assignment 3 - Applied Data Science - 2.3 | eyavuz21 | 8 | 6,558 |
Jun-06-2020, 08:59 AM Last Post: eyavuz21 |
|
Python Password Saver Assignment | sshellzr21 | 2 | 7,248 |
May-02-2020, 01:34 AM Last Post: sshellzr21 |
|
Python for Everybody 3.3 assignment | ramadan2099 | 7 | 33,759 |
Apr-08-2020, 06:49 AM Last Post: DeaD_EyE |
|
Python for everyone course assignment 5.2 | ofekx | 3 | 9,579 |
Dec-23-2019, 08:41 PM Last Post: nilamo |
|
[split] Python for Everybody 5.2 assignment | jonchanzw | 4 | 9,548 |
Oct-22-2019, 08:08 AM Last Post: perfringo |
|
Python Assignment 5.2 | amos76823 | 3 | 16,961 |
Jan-17-2019, 07:34 AM Last Post: perfringo |