Question: can anyone help me out on the below python code def total_weight(width_tile, length_tile, number_of_tiles): Given the dimensions of a tile (width and length in cm)
can anyone help me out on the below python code
def total_weight(width_tile, length_tile, number_of_tiles): """Given the dimensions of a tile (width and length in cm) and the number of tiles ordered, calculate total weight of the tiles that have been ordered.""" def getWeight(numberoftiles,dimensions): weightPercmSquare = 10 print(dimensions) area = dimensions[0]*dimensions[1] print(area) weightOfOneTile = weightPercmSquare*area totalWeight = weightOfOneTile*numberoftiles return totalWeight
n = int(input("Enter the number of tiles you want to find the weight for : ")) length,breadth = map(int,input("Enter the dimensions (length and width) of a single tile : ").split()) print("Total weight of the tiles : ",getWeight(n,[length,breadth])," grams")
# INSERT YOUR CODE BELOW FOR CALCULATING THE # TOTAL WEIGHT AND RETURNING THE RESULT (DO NOT CHANGE # THE HEADER OF THE FUNCTION WHICH HAS BEEN PROVIDED FOR YOU # ABOVE)
# DO NOT CHANGE THE CODE BELOW # The code below automatically tests your function # following the approach described in # Before you make any changes to this file, # when you run it, you will get an AssertionError. # Once you have completed the file with correct # code, the AssertionError should no longer appear and # message "tests passed" will appear in the shell.
def test_total_weight(): """Test the total_weight() function.""" # Test for tile with dimensions 20, 20 and # order of 30 tiles assert total_weight(20, 20, 30) == 120000 # Test for tile with dimensions 1, 1 and # order of 1 tile assert total_weight(1, 1, 1) == 10 # Test for tile with dimensions 10, 0 and # order of 10 tiles assert total_weight(10, 0, 10) == 0
# Test for tile with dimensions 0, 10 and # order of 15 tiles assert total_weight(0, 10, 15) == 0 # Test for brick with dimensions 1, 1 and # order of 0 tiles assert total_weight(1, 1, 0) == 0 print ("tests passed") test_total_weight()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
