Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Appel, Matthew
- #Practice Program
- #10/23/2010
- def main():
- import string
- calculate = True
- while calculate == True: #Sentitel value, when user doesn't want to run it again, sets calculate to False
- print()
- length = int(input("Please enter the length in square feet: "))
- width = int(input("Please enter the width in square feet: "))
- price = int(input("Please enter the price of carpet in $ per square yard: "))
- area = (length * width)/9
- totcost = (area * price)
- if totcost <= 500 and price > 0 and price < 100:
- print()
- print("I'll buy it for $",totcost)
- print()
- 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.
- if getout == "N":
- calculate = False
- elif getout == "Y":
- calculate = True
- else:
- print()
- print(getout,"is an invalid input")
- print()
- input("Press enter to start over")
- calculate = True
- elif (price < 0 or price > 100) and test < 10:
- print()
- print("Please Try again")
- else:
- print()
- print("$",totcost,"is too much for me!")
- print()
- getout = string.capwords(input("Would you like to calculate another?(Y/N) "))
- if getout == "N":
- calculate = False
- elif getout == "Y":
- calculate = True
- else:
- print()
- print(getout,"is an invalid input")
- print()
- input("Press enter to start over")
- calculate = True
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement