Question

In: Computer Science

IN PYTHON ( Use Fuctions and or with Loop if comfortable) Your friends just bought a...

IN PYTHON ( Use Fuctions and or with Loop if comfortable)

Your friends just bought a new five room house and need your help to know how much it will cost to re-do the floors. Write a program that, given the dimensions of each of the five rooms and the desired type of flooring, outputs the cost of each room as well as the total cost. Hardwood costs $1.39/sqft, carpet costs $3.99/sqft, and tile costs $4.99/sqft. Input Validation: Your program must work regardless of the case the floor option is typed in and any blank spaces surrounding it; If an invalid option is given, inform the user it was invalid and that you will be skipping that room (treat the cost as zero). Round: Use the round function to round your output to two decimal places.

Solutions

Expert Solution

code :

output :

raw_code :

cost = 0
#loop for five rooms
for i in range(1,6):
print('Room : ',str(i))
#taking inputs
length = float(input('Length : '))
width = float(input('Width : '))
floor = input('Flooring : ')
#checking invalid condition
if (floor not in ['Hardwood','carpet','tile']):
print('Invalid type')
continue
#calculating cost
else:
if(floor == 'Hardwood'):
cost += length*width*1.39
elif(floor == 'carpet'):
cost += length*width*3.99
else:
cost += length*width*4.99

#displaying cost with two decimals
print('Cost to re-do floors is $',round(cost,2))

***do comment for queries and rate me up***


Related Solutions

Problem IN PYTHON ( Use Fuctions and or with Loop if comfortable) Your friends just bought...
Problem IN PYTHON ( Use Fuctions and or with Loop if comfortable) Your friends just bought a new five room house and need your help to know how much it will cost to re-do the floors. Write a program that, given the dimensions of each of the five rooms and the desired type of flooring, outputs the cost of each room as well as the total cost. Hardwood costs $1.39/sqft, carpet costs $3.99/sqft, and tile costs $4.99/sqft. Input Validation: Your...
You bought a book, a winter hat, and a cupcake for Christmas gifts for your friends....
You bought a book, a winter hat, and a cupcake for Christmas gifts for your friends. There are seven friends (Danise, Caitlin, Matt, Stephen, Christy, Kyoungmin, Juna) among whom you will randomly choose three friends and give each of them Christmas gift. a. What is the probability that Danise, Christy, and Juna will receive a book, a cupcake, and a winter hat, respectively? b. What is the probability that Danise, Chirsty, and Juna will receive Christmas gift from you?
Python Write a for loop with a range function and format output as currency Use an...
Python Write a for loop with a range function and format output as currency Use an input statement to ask the user for # of iterations using the prompt: #? [space after the ?] & assign to a variable Convert the variable to an integer Use a for loop and a range function to display all whole numbers from 1 to the user entered number Display the value of the item variable on screen in each iteration in the following...
Python Loop invariant To show that an assertion A is a loop invariant , is it...
Python Loop invariant To show that an assertion A is a loop invariant , is it enough to argue that the execuation of the loopbody preserves A? Please desscribe it throughly.
Using Python, use the following list (Temperature = [56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]) to: - Create a loop to iterate...
Using Python, use the following list (Temperature = [56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]) to: - Create a loop to iterate through each of the elements in the temperature list. - Convert each element of this list to a Celsius temperature and then, for each valid temperature in the list, print out both the original Fahrenheit temperature and the Celsius equivalent in this format: "32 degrees Fahrenheit is equivalent with 0 degrees Celsius."
Important: please use python. Using while loop, write python code to print the times table (from...
Important: please use python. Using while loop, write python code to print the times table (from 0 to 20, incremented by 2) for number 5. Add asterisks (****) so the output looks exactly as shown below.   Please send the code and the output of the program. ****************************************************************** This Program Shows Times Table for Number 5 (from 0 to 20) Incremented by 2 * ****************************************************************** 0 x 5 = 0 2 x 5 = 10 4 x 5 = 20 6...
To detox or not isn't just a topic of discussion for you and your friends. It's...
To detox or not isn't just a topic of discussion for you and your friends. It's one that is debated regularly among health care practitioners. Detoxification has been practiced for centuries by many cultures around the world. Research a body detoxification method and whether you agree with the practice or not
Use python Only can use if statement and loop, that's professor's requirement I have no idea...
Use python Only can use if statement and loop, that's professor's requirement I have no idea how to do that without class Building Entrance Tracker Due to Covid-19, we can allow only 5 guests to our building at a time. Our task is to write a program that helps the entrance staff to keep track of guest entries to the building. Feature 1 (40 points): Each guest must sign in upon entry into the building. If the number of guests...
python Write a Loop class. The contents of a loop object are represented internally as a...
python Write a Loop class. The contents of a loop object are represented internally as a simple python list with the following additional instance variables: loop - a python list containing the elements of the loop list head - which stores the index of the first element of the loop list current - which stores the index of the last element of the loop list size - which stores how many actual elements are in the loop max - which...
must use python Write a nested for loop that displays the following output using the same...
must use python Write a nested for loop that displays the following output using the same integer from part a:                                                     1                                                 1   2   1                                             1   2   4   2   1                                         1   2   4   8   4   2   1                                     1   2   4   8 16   8   4   2   1                                 1   2   4   8 16 32 16   8   4   2   1                             1   2   4   8 16 32 64 32 16   8   4   2   1                         1   2   4  ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT