Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None | 0 0
  1. #Appel, Matthew
  2. #Practice Program
  3. #10/23/2010
  4.  
  5. def main():
  6.     import string
  7.     calculate = True
  8.     while calculate == True: #Sentitel value, when user doesn't want to run it again, sets calculate to False
  9.         print()
  10.         length = int(input("Please enter the length in square feet: "))
  11.         width = int(input("Please enter the width in square feet: "))
  12.         price = int(input("Please enter the price of carpet in $ per square yard: "))
  13.         area = (length * width)/9
  14.         totcost = (area * price)
  15.         if totcost <= 500 and price > 0 and price < 100:
  16.             print()
  17.             print("I'll buy it for $",totcost)
  18.             print()
  19.             getout = string.capwords(input("Would you like to calculate another?(Y/N) ")) #string.capwords() takes the input and makes sure it's capital, this helps prevent errors when asking to repeat it.
  20.             if getout == "N":
  21.                 calculate = False
  22.             elif getout == "Y":
  23.                 calculate = True
  24.             else:
  25.                 print()
  26.                 print(getout,"is an invalid input")
  27.                 print()
  28.                 input("Press enter to start over")
  29.                 calculate = True
  30.         elif (price < 0 or price > 100) and test < 10:
  31.             print()
  32.             print("Please Try again")
  33.         else:
  34.             print()
  35.             print("$",totcost,"is too much for me!")
  36.             print()
  37.             getout = string.capwords(input("Would you like to calculate another?(Y/N) "))
  38.             if getout == "N":
  39.                 calculate = False
  40.             elif getout == "Y":
  41.                 calculate = True
  42.             else:
  43.                 print()
  44.                 print(getout,"is an invalid input")
  45.                 print()
  46.                 input("Press enter to start over")
  47.                 calculate = True
  48. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement