Advertisement
Mars83

2-3

Oct 3rd, 2011
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #! /usr/bin/env python3.2
  2. # -*- coding: utf-8 -*-
  3.  
  4. # main.py
  5. """ Task: Exercise 2.3
  6.    Write a program to prompt the user for hours and rate per hour to compute
  7.    gross pay.
  8.    Enter Hours: 35
  9.    Enter Rate: 2.75
  10.    Pay: 96.25
  11.    We won't worry about making sure our pay has exactly two digits after the
  12.    decimal place for now. If you want, you can play with the built-in Python
  13.    round function to properly round the resulting pay to two decimal places.
  14. """
  15.  
  16. # Main
  17. hours = input("Enter Hours: ")
  18. rate = input("Enter Rate: ")
  19. pay = round(float(hours) * float(rate), 2) # round to 2 digits
  20.                                            # float() casts str to float
  21. print("Pay: " + str(pay))                  # str() casts float to string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement