tile_fitting(num_small, num_large, length) Description: You have tiles of two different fixed sizes, 1ft and 5ft long, and you want to decide whether a certain number of these tiles can fit exactly a certain length (we do not care about the other dimension). It’s ok if you have more tiles than needed but not the opposite obviously. Parameters: num_small (int) is the amount of the available small tiles (1ft), num_large (int) is the amount of the available large tiles (5ft), and length (int) is the length (in ft) you want to cover. Return value: True if the available tiles can fit exactly the given length and False otherwise.

Respuesta :

Answer:

Python script for the problem explained below with appropriate comments

Explanation:

import math

def tile_fitting(num_small,num_large,length): #tile_fitting() function definition

number_of_fives=math.floor(length/5) #calculating number of 5ft tiles required to cover given length

number_of_ones=length%5 #calculating number of 1ft tiles required to cove given length

#if num_small is greater than required 1ft tiles and num_large is greater than required 5ft tiles

if(num_small>=number_of_ones and num_large>=number_of_fives):

return True #returning True to the caller function

else: #else

return False #returning False to the caller function

num_small=int(input("Enter number of 1ft tiles: ")) #reading number of 1ft tiles from user

num_large=int(input("Enter number of 5ft tiles: ")) #reading number of 5ft tiles from user

length=int(input("Enter the length you want to cover: ")) #reading length to cover from user

#calling tile_fitting() function by passing num_small,num_large and length

print(tile_fitting(num_small,num_large,length))