Python Forum
Count how many carpets you need to fill room floor without multiplication/division
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Count how many carpets you need to fill room floor without multiplication/division
#1
Hey, I've got this task to coplete. I must do it using While:
Room length is A meters and with is B. How many square carpets, which have an edge of C meters, do you need to fully fill a room? You can't use multiplication or division.

a=float(input('What is the length of the room? '))
b=float(input('What is the width of the room? '))
c=float(input('What is the length of square carpet edge? '))
i=0
while a >= c:
    a = a - c
    i = i + 1
print(i)
I could only manage to count one column of carpets and whey won't fill the floor completely if the length was a float number.
Reply
#2
First, do it with while a > 0:. That will cover the fractional portion. That assumes the carpets are meant to be kept whole, and therefore overlap to cover fractional spaces. I think that is necessary to the problem, but you should clarify that with your teacher.

Then, do another while loop where you subtract c from b. Instead of adding one, and the number of carpets to fill the length of the room.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  If statements and multiplication elroberto 1 1,658 Jun-22-2022, 05:35 PM
Last Post: deanhystad
  Zero Division Error Leo 2 1,207 Mar-25-2022, 05:56 AM
Last Post: Leo
  Finding square roots using long division. jahuja73 10 5,301 Feb-24-2021, 01:25 PM
Last Post: jahuja73
  Find the maximum multiplication ercv 3 2,097 Nov-30-2020, 11:55 AM
Last Post: DeaD_EyE
  Division problem Eric7Giants 1 1,666 Nov-16-2019, 05:50 AM
Last Post: ndc85430
  Zero Division Error moga2003 4 3,055 Mar-07-2019, 02:15 AM
Last Post: moga2003
  Multiplication Table Homework mcnhscc39 6 4,526 Nov-25-2018, 04:01 PM
Last Post: mcnhscc39
  Count Letters in a Sentence (without using the Count Function) bhill 3 5,065 Jun-19-2018, 02:52 AM
Last Post: bhill
  creating a 3x3 multiplication table aditvaddi 1 3,585 Jun-18-2018, 06:05 AM
Last Post: volcano63
  Multiplication Table funnybone04 4 5,713 Apr-08-2018, 03:03 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020