Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compute gross pay
#1
please give a runnable sample of your code with the full error text or a clear description of the problem

pay: 472.5 ← Mismatch

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:")
xp = float (hrs) * float (rate)
print ("pay:", xp)
Reply
#2
You're not paying the hours over 40 at 1.5 the hourly rate. You need to figure that into your calculation. I would put in an if statement to check if the hours are over 40, and then if they are, add the extra to xp.

And please use python tags for your code, see the BBCode link in my signature below for instructions.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Maths and python: Compute stress level cheerful 1 2,721 Oct-20-2021, 10:05 AM
Last Post: Larz60+
  Compute complex solutions in quadratic equations liam 1 1,889 Feb-09-2020, 04:18 PM
Last Post: Gribouillis
  How to compute conditional unigram probabilities? jbond 2 2,521 Jan-25-2020, 02:58 PM
Last Post: jbond
  Beginner Python Homework Question (Calculate Gross Pay) matchamochi7 4 5,686 Nov-02-2018, 01:06 PM
Last Post: buran
  To extract a specific column from csv file and compute the average vicson 2 8,111 Oct-20-2018, 03:18 AM
Last Post: vicson
  Write a program to compute the sum of the terms of the series: 4 - 8 + 12 - 16 + 20 - chewey777 0 2,815 Mar-24-2018, 12:39 AM
Last Post: chewey777
  How do you compute tf-idf from a list without using the counter class syntaxkiller 8 5,234 Dec-01-2017, 05:24 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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