I've made a small program that calculates the cost of flooring for a given area based on the price per sqft and total sqft. I have only been programming for a few days now so I am sure that there are some things I could be doing better.
from decimal import *
import time
print("This program will help you find the cost of floor covering\n")
def program():
exit_program = ["q", "Q"]
global move_on
move_on = ["y", "Y"]
global more_info
more_info = ["n", "N"]
cost_of_tile = Decimal(input("What is the cost of the tile per square foot?"))
global answer
answer = input("Do you know how big the room is in sqft? Y/N")
if answer in move_on:
global sqft
sqft = Decimal(input("Please enter the room's size in SQUARE FEET"))
print("The cost to cover your floor will be $%s" % (sqft * round(cost_of_tile, 2)))
labor()
answer = input("Would you like to run the calculator again for another room? Y/N")
should_i_stay()
elif answer in more_info:
answer = input("Do you know the length and the width of the room? Y/N")
if answer in move_on:
width = Decimal(input("What is the width of the room?"))
length = Decimal(input("What is the length of the room?"))
sqft = width * length
print("Your room is %s sqft" % sqft)
print("The cost to cover your room will be $%s" % (sqft * round(cost_of_tile, 2)))
labor()
elif answer in more_info:
print("Sorry we need more information ")
answer = input("Would you like to run the calculator again? Y/N")
should_i_stay()
elif answer in exit_program:
print("Exiting")
exit()
def should_i_stay():
if answer in move_on:
program()
else:
print("Good Bye")
time.sleep(1)
exit()
def labor():
rate = 86
total_labor = (sqft / 20) * rate
hours_of_labor = sqft / 20
if hours_of_labor <= 1:
hours_of_labor = 1
total_labor = rate
print("The labor will be approximately $%s at a rate $%s per "
"hour for a total of %s hours of labor" % (round(total_labor, 2), rate, hours_of_labor))
else:
print("The labor will be approximately $%s at a rate $%s per "
"hour for a total of %s hours of labor" % (round(total_labor, 2), rate, hours_of_labor))
program()