1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
brilliants [131]
2 years ago
10

Create a Python program that computes the cost of carpeting a room. Your program should prompt the user for the width and length

in feet of the room and the quality of carpet to be used. A choice between three grades of carpet should be given. You should decide on the price per square foot of the three grades on carpet. Your program must include a function that accepts the length, width, and carpet quality as parameters and returns the cost of carpeting that room. After calling that function, your program should then output the carpeting cost. of carpeting a room. Note: the output is NOT in the function but in the main. Display your name,class,date as per SubmissionRequirements by using a function.
Your program should include your design steps as your comments. Document the values you chose for the prices per square foot of the three grades of carpet in your comments as well.
Computers and Technology
1 answer:
allochka39001 [22]2 years ago
8 0

Answer:

In Python:

def calcCost(length,width,quality):

   if quality == 1:

       cost = length * width * 3.50

   if quality == 2:

       cost = length * width * 2.50

   else:

       cost = length * width * 1.50

   

   return cost

   

length = float(input("Room Length: "))

width = float(input("Room Width: "))

print("Quality:\n1 - Best\n2 - Moderate\n3 and others - Worst")

quality = int(input("Quality: "))

print("Calculate: "+str(calcCost(length,width,quality)))

Explanation:

This defines the function calcCost to calculate the carpeting cost

def calcCost(length,width,quality):

If quality is 1, the total cost is calculated by area * 3.50

<em>    if quality == 1:</em>

<em>        cost = length * width * 3.50</em>

If quality is 2, the total cost is calculated by area * 2.50

<em>    if quality == 2:</em>

<em>        cost = length * width * 2.50</em>

For other values of quality, the total cost is calculated by area * 1.50

<em>    else:</em>

<em>        cost = length * width * 1.50</em>

This returns the calculated carpeting cost    

   return cost

   

The main begins here

This prompts the user for the length of the room

length = float(input("Room Length: "))

This prompts the user for the width of the room

width = float(input("Room Width: "))

This gives instruction on how to select quality

print("Quality:\n1 - Best\n2 - Moderate\n3 and others - Worst")

This prompts the user for the quality of the carpet

quality = int(input("Quality: "))

This calls the calcCost method and also printst the calculated carpeting cost

print("Calculate: "+str(calcCost(length,width,quality)))

You might be interested in
How do you open Microsoft Excel 2013 with Windows 8?
adell [148]
Go to the apps page. When you get there find the search bar, and once you find the search bar, click in it and type in Microsoft Excel 2013. The application will come, click on it and it will open. *Note:- This is only if you have already downloaded it on your computer/laptop, or if it came with your laptop/computer.*

Hope I helped ya!! xD
8 0
3 years ago
To add text to a slide when using presentation software, you need to add a text box. To add a text box, click the Text Box butto
Amiraneli [1.4K]

The answer is the second choice, "Insert."


On Microsoft Powerpoint, when you click on the insert tab you can find the text box button.

3 0
3 years ago
Read 2 more answers
Creating a chart using a spreadsheet Chart Wizard involves four steps. Which is the last step?
oksian1 [2.3K]
Hey there!

The correct answer to your question will be finding the location for the chart.

Creating a chart using a spreadsheet Chart Wizard involves four steps.
The last step is to find where the chart should be located.
After you are done following the steps of making it, you apply it to a location you find is best to put it.


Hope this helps you.
Have a great day! :)
8 0
3 years ago
Victoria has a .... of playing with her hair when she gets nervous​
IrinaK [193]

Answer:

Victoria has a tendency of playing with her hair when she gets nervous.

Explanation:

I believe this is what you are asking for.

:))))

6 0
3 years ago
What is the name for an object that is what it appears to be?
Gnesinka [82]
That would be a symbol
8 0
3 years ago
Other questions:
  • Write an original idiom that uses the word dog or dogs im in 4th
    5·2 answers
  • Another html/css assignment, drop css code below, thank you
    15·1 answer
  • One of the disadvantages of an e-marketplace is that it cannot provide a single platform for prices. true or false?
    10·2 answers
  • How do you know if your phone has a virus?
    13·1 answer
  • The command button to protect a document is part of the​.
    10·1 answer
  • Next, Leah wants to add a content slide that allows her to insert a table.
    8·2 answers
  • Write a program to read a list of exam scores given as integer percentages in the range O to 100. Display the total number of gr
    11·1 answer
  • What sorts of changes have you been observing in your society in your society in comparison in last 3 years​
    13·1 answer
  • Project introduction​
    14·1 answer
  • How do I create a simple percentage function to gather a score for a quiz in PHP?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!