NOTE : Is learning \"Python programming\" (currently on chapter 5) with the foll
ID: 3585709 • Letter: N
Question
NOTE: Is learning "Python programming" (currently on chapter 5) with the following textbook:
1. A painting company has determined that for every 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges S35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon. Do not let the user enter negative numbers. Use a function named get number that takes one parameter, a string. That string should contain the prompt that you will use for input. get _number should ask the user for a number until the user enters a non-negative number (so 0 is ok), then return the valid number as a float. Feel free to use any other functions you wish The program should display the following data: » The number of gallons of paint required (rounded up) The hours of labor required (rounded up) . The cost of the paint » The labor charges » The total cost of the paint job Remember, to round up, you can use math.ceil(num) /workspace/HW/ $ python number01.py Enter the number of square feet to be painted: 500 How much does the paint cost? 25.64 This job requires: 5 gallons of paint 36 hours of labor Costs for the iobExplanation / Answer
Hi Let me know if you need more information:-
==============================================
import math
#!/usr/bin/python
toPainted = 0;
painCost = 0;
while True:
toPainted = float(input("Enter the number of square to be painted: "))
if toPainted > 0:
break
else:
print("You must enter a positive number.")
#print (toPainted)
while True:
painCost = float(input("How much does the paint cost? "))
if painCost > 0:
break
else:
print("You must enter a positive number.")
#print (painCost)
print(" ")
gallons = math.ceil(toPainted/112)
labor = math.ceil((toPainted * 8)/112)
print("This job requires:")
print(gallons," gallons of paint")
print(labor," hours of labor")
paint = (painCost * gallons);
labor = (labor * 35);
print(" ")
print("Costs for the job:")
print("Paint: $",format(paint,'.2f'))
print("Labor: $",format(labor,'.2f'))
print("Total: $",format((labor + paint),'.2f'))
============
OUTPUT:-
===========
============
Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.