Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 New to python via Prof Chuck Severance
#1
Hello everyone,

I am Paul and began taking python online thru Prof Chuck Severance py4e.com.

Just wanted to ask if anyone can help in correcting assignments.

According to the code checker, there's a mismatch on the results, and my code needs correction.

The output of this message does not indent my code. The lines after each "if" statement have been indented.

Thanks in advance for any feedback!

Assignment 3.1 py4e
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.


The output is 498.75

Here's my code:

hrs=float(input("Enter Hours: "))
if hrs <= 40 :
    rate=float(input("Enter Rate: "))
    pay=float(hrs)*float(rate)
    print("Gross pay is ",pay)
if hrs > 40 :
    rate=float(input("Enter Rate: "))
    pay=float(40)*float(rate)
    overtimehrs=hrs-40
    overtimerate=float(rate)*1.5
    overtimepay=float(overtimehrs)*overtimerate
    grossotpay=pay + overtimepay
    print("Gross pay is ",grossotpay)
buran wrote May-23-2020, 04:42 AM:
Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.
Quote
#2
Place your code within tags when posting so that its readable. You can refer to the instructions in the below link.
https://python-forum.io/misc.php?action=help&hid=25

You could have made some mistake while indenting, otherwise your code is fine.
Quote
#3
It looks like the website is looking for:
Output:
498.75
Your code is outputting this instead:
Output:
Gross pay is 498.75
Quote
#4
What is the error that you are getting?
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)