Question: here is my code : def num _ tiles ( ) : tray _ width = float ( input ( What is the width

here is my code :
def num_tiles():
tray_width = float(input("What is the width of the tray? "))
tray_height = float(input("What is the height of the tray? "))
tile_width = float(input("What is the width of the tile? "))
tile_height = float(input("What is the height of the tile? "))
# Calculate the area of the tray and tile
tray_area = tray_width * tray_height
tile_area = tile_width * tile_height
# Calculate number of tiles without rotation
tiles_no_rotation =(tray_width // tile_width)*(tray_height // tile_height)
# Calculate number of tiles with rotation
tiles_with_rotation =(tray_width // tile_height)*(tray_height // tile_width)
# Max number of tiles (choosing between rotated and non-rotated arrangement)
max_tiles = int(max(tiles_no_rotation, tiles_with_rotation))
# Calculate total area occupied by tiles
total_tile_area = max_tiles * tile_area
# Calculate unoccupied area in the tray
unoccupied_area = tray_area - total_tile_area
# Output the results
print(f"The tray has width {round(tray_width, 1)} and height {round(tray_height, 1)} and area {round(tray_area, 1)}")
print(f"The tiles have width {round(tile_width, 1)} and height {round(tile_height, 1)} and area {round(tile_area, 1)}")
print(f"The maximum number of tiles in the tray is {max_tiles}")
print(f"The total area of the tiles is {round(total_tile_area, 1)} and the unoccupied area in the tray is {round(unoccupied_area, 1)}")
# Run the function
num_tiles()
I have been trying for hours and it hasnt been working what is the solution so that i can get the expected outputs (in green ) and not get whats in red (wrong).What is the width of the tray? 68
What is the height of the tray? 91
What is the width of the tile? 5
What is the height of the tile? 10
The tray has width 68.0 and height 91.0 and area
6188.0
The tiles have width 5.0 and height 10.0 and area
50.0
The maximum number of tiles in the tray is 123
The total area of the tiles is 6150.0 and the
unoccupied area in the tray is 38.0
The maximum number of tiles in the tray is 117
The total area of the tiles is 5850.0 and the
unoccupied area in the tray is 338.0What is the width of the tray? 68
What is the height of the tray? 91
What is the width of the tile? 5
What is the height of the tile? 10
The tray has width 68.0 and height 91.0 and area
6188.0
The tiles have width 5.0 and height 10.0 and area
50.0
The maximum number of tiles in the tray is 123
The total area of the tiles is 6150.0 and the
unoccupied area in the tray is 38.0
The maximum number of tiles in the tray is 117
The total area of the tiles is 5850.0 and the
unoccupied area in the tray is 338.0
(The picture is one example of the tests but do know that there are many hidden tests that i dont have acces to , so please make it as robust as you possibly can...)
here is my code : def num _ tiles ( ) : tray _

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!