Geeks of Coding

Join us on Telegram

Home Forums Cody Bank Getting Started with Python

Viewing 1 reply thread
  • Author
    • #710
      Abhishek TyagiAbhishek Tyagi

      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 = raw_input("Enter Hours:")
      h = float(hrs)
      rph = float(raw_input("Enter rate per hour"))
      if hrs > 40:
          print (40*rph + (h-40)*rph*1.5)
          print (h*rph)



    • #711
      Abhishek TyagiAbhishek Tyagi

      3.3 Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table:
      #Score Grade
      #>= 0.9 Show A
      #>= 0.8 Show B
      #>= 0.7 Show C
      #>= 0.6 Show D
      #< 0.6 Show F
      #If the user enters a value out of range, print a suitable error message and exit. For the test, enter a score of 0.85.

      x = float(raw_input("Enter Score"))
      if x <= 1 and x > 0:
          if x >= 0.9:
              print ("A")
          elif x >= 0.8:
              print ("B")
          elif x >= 0.7:
              print ("C")
          elif x >= 0.6:
              print ("D")
          elif x < 0.6:
              print ("D")
          print ("error")
Viewing 1 reply thread
  • You must be logged in to reply to this topic.