Jun-19-2020, 10:59 AM
Hey all, so my course given me another tricky one, i think i get the idea of it, just trying to finding the right way of writing it. My tutor has said that a if, else then statement is best to be used.
The take is to find out the kg of cargo to cubic meters and how many can fit in to a container.
So the container is 67.5 volume and has a net weight of 26199kg.
Many thanks Sam
The take is to find out the kg of cargo to cubic meters and how many can fit in to a container.
So the container is 67.5 volume and has a net weight of 26199kg.
def volume_per_container(kg_cargo_per_cubic_metre): """Given the kg of cargo per cubic metre, calculate how many cubic metres of cargo can be stored in a single container.""" if 26199 == 67.5: 1800 * 14.555 = 26199 <= 67.5 elif: 380 * 68.94 = 26.197 >= 67.5 elif: 380 * 67.5 = 25.650 <= 67.5 return # INSERT YOUR CODE BELOW FOR CALCULATING THE # TOTAL VOLUME AND RETURNING THE RESULT (DO NOT CHANGE # THE HEADER OF THE FUNCTION WHICH HAS BEEN PROVIDED FOR YOU # ABOVE) def test_volume_per_container(): """Test the volume_per_container function.""" # Test for gravel at 1800 kg per cubic metre assert volume_per_container(1800) == 14.555 # Test for wood chips at 380 kg per cubic metre assert volume_per_container(380) == 67.5 print ("tests passed") test_volume_per_container()Am i heading in the right direction? Not looking for the answer, mainly just pointers if i am doing this completely wrong. I get syntax errors but i cant figure out a better way of writing this code out.
Many thanks Sam