Python Forum
Subtle Bug I really don't see in Autograder: Exercise 3.1
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subtle Bug I really don't see in Autograder: Exercise 3.1
#1
I know for sure the code is correct but the autograder doesn't recognize it as good and keeps giving me the same message,which is "You must read the data using input() and then convert it."
What is wrong here!??!
Here's the Assignment:
3.1 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input - assume the user types numbers properly.

hrs = input("Enter Hours:")
rate = input("Enter Rate:")
h = float(hrs)
r = float(rate)

if h <= 40:
    print(h * r)
else:
    extra = (h - 40) * (10.5 * 1.5)
    print(40 * r + extra)
buran write Dec-21-2020, 06:08 PM:
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
Your next-to-last line isn't using the input rate, it's using a hard-coded rate.
perfringo likes this post
Reply
#3
I find it interesting when this assignment pops up, and it pops up a lot, that none of the posts solve it by adjusting the hours. I've always heard this kind of overtime referred to as "time and a half". This must not be a common slang or else we should see this as the equation for calculating pay.

hours = hours + 0.5 * max(0, hours-40)
pay = hours * rate

bowlofred is correct. The rate used for overtime pay is fixed at 10.5. You would have known there was a problem with overtime pay if you bothered to test your program. One test case, particularly one test case that is provided with the assignment, is not adequate testing.
Reply
#4
(Dec-21-2020, 07:13 PM)deanhystad Wrote: I find it interesting when this assignment pops up, and it pops up a lot, that none of the posts solve it by adjusting the hours. I've always heard this kind of overtime referred to as "time and a half". This must not be a common slang or else we should see this as the equation for calculating pay.

hours = hours + 0.5 * max(0, hours-40)
pay = hours * rate

bowlofred is correct. The rate used for overtime pay is fixed at 10.5. You would have known there was a problem with overtime pay if you bothered to test your program. One test case, particularly one test case that is provided with the assignment, is not adequate testing.

Hey man,trust me, your judgmental post doesn't really help.I did bothered to test the program more than once,I couldn't figure out what the problem was,that's why I asked.If you have some issues with yourself just don't answer at all
Reply
#5
(Dec-21-2020, 05:40 PM)benante3 Wrote: I know for sure the code is correct but the autograder doesn't recognize it as good and keeps giving me the same message,which is "You must read the data using input() and then convert it."
What is wrong here!??!
Here's the Assignment:
3.1 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input - assume the user types numbers properly.

hrs = input("Enter Hours:")
rate = input("Enter Rate:")
h = float(hrs)
r = float(rate)

if h <= 40:
    print(h * r)
else:
    extra = (h - 40) * (10.5 * 1.5)
    print(40 * r + extra)


Goddamit, it makes total sense!thanks a lot!one of those little stupid details I didn't think about
Reply
#6
(Dec-21-2020, 09:15 PM)benante3 Wrote: Hey man,trust me, your judgmental post doesn't really help.I did bothered to test the program more than once,I couldn't figure out what the problem was,that's why I asked.If you have some issues with yourself just don't answer at all
You were under the impression that your program worked, and couldn't understand why it didn't pass. A test with overtime and a different rate would show that your program was not computing the correct value. Once you knew that I'm sure you would quickly zero in on the problem. I am not being judgmental, just saying that proper testing is how you find problems. You obviously did not test the code very well or you would have found the problem yourself. Make more test cases to exercise all the code. This code requires a minimum of 6 tests. Time = 40 hours, time < 40 hours, time > 40 hours. Each time computed with two different rates. I would also test with time = 0 and rate = 0. If this was real code you would also test for negative cases and you would test the input.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  A bug in my school's autograder DontPanic 1 1,617 Oct-14-2020, 09:04 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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