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]
3 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]3 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
Me pueden ayudar a hacer un proyecto de tecnología? mi fb es Erick Escaron (foto de perfil de free fire y dice veterano)
trapecia [35]

Answer:

tecnología? mi fb es Eri

8 0
3 years ago
(Python question)
Law Incorporation [45]

Hey!

---------------------------------------------------

Definition:

A "for loop" is something used for repeating things over a list of items. For instance, a list or a dictionary.

Code:

colors = ["red", "green", "blue"]

for x in colors:

 print(x)

---------------------------------------------------

Definition:

A "while loop" is is something used for carrying out a set of lines that are true.

Code:

n = 1

while i < 4:

 print(n)

 n += 1

---------------------------------------------------

Real-Life Example:

A real-life example would if I was a manager or boss for a company say that everyone was off a certain day. Like, if I said everyone was off for Christmas the 25th. If I had 1000 employees that would take a very long time to send an email to everyone. Instead of sending an email to everyone I can program code that uses "for loops" and "while loops" to create a message and send it to everyone.

---------------------------------------------------

Hope This Helped! Good Luck!

3 0
3 years ago
Read 2 more answers
Which of the following is not a property of a constructor?A. The name of a constructor can be chosen by the programmerB. A const
inna [77]

Answer:

The answer is "Option A"

Explanation:

The constructor is a special member function whose task is to initialize an object from its class, and it doesn't return any value like int, float, double, etc. Its name and class name will always be the same, and when we create the class object so, the constructor is automatically called, and it may be overloaded, that's why we can say that except the "choice A", all were correct.

4 0
3 years ago
Which of the following is not an operating system service?
skad [1K]

Answer:

c. graphical user interface

Explanation:

An operating system may be defined as the system software which manages the various computer hardware, resources, software and also provides other computer services. It communicates the user with the computer and the computer runs according to the instruction provided by the operating system. It is commonly known as the OS.  

Operating system does not provide any graphical user interface. It consists of necessary components of the software to facilitate the usage or running of the computer.

5 0
3 years ago
____ formatting is automatically updated if you change data in the worksheet.
andriy [413]

Answer:

<u>Conditional</u> formatting is automatically updated if you change data in the worksheet.

Explanation:

Conditional formatting can be described as a tool that allows users to format a particular cell or a group of cells. The formatting also changes for any data being changed in the sheet.

A particular cell can have up to three format conditions and these conditions will be applied automatically to any changes entered in the cell. The conditional formatting also has the option to highlight the important cells.

4 0
3 years ago
Other questions:
  • Xml provides a standardized, non-customizable way to describe the content of a document.
    9·1 answer
  • Special effects are added using the _____.
    16·1 answer
  • When someone registers a domain name that is a company's trademark, hoping to resell it to the company at an exorbitant profit,
    14·2 answers
  • Order the following routine maintenance tasks from most to least important when securing a computer. a. Verify anti-malware sett
    15·1 answer
  • I need an answer and fast What happens if a sequence is out of order?
    5·2 answers
  • Explain 3 ways you can be an upstander when seeing cyberbullying.
    13·2 answers
  • Help me with this, please. Are vacuum cleaners, Cd players, and telephones considered computers? Do they store any data or proce
    8·2 answers
  • Explain the characteristics of a first generation computer​
    8·1 answer
  • At Greenwood ATCT, arrival information need NOT be forwarded while FDIO is operational unless the sequence of aircraft changes a
    6·1 answer
  • to protect a windows 10 system, you've configured system restore to automatically protect your system using restore points. will
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!