Python Forum

Full Version: New to coding. need som help with an assignement.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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."""

    # 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)
    


# DO NOT CHANGE THE CODE BELOW 
# The code below automatically tests your function
# following the approach described in 
# Block 2 Part 4 (Page 207 and further).
# If you run this file before making any changes to
# 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_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
   
    
    print ("tests passed") 
  
test_volume_per_container()
What do you need help with, you forgot to put the code you have so far where it says
# 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)
Hi yoriz, that's the assignment. I have been unable to add anything that would complete the tests.

in this instance the max net weight = 26188

when I put the formula in
max net weight/product.

problem I get is I have no idea on how to create a section of code which will then test accurately.
https://python-forum.io/misc.php?action=help&hid=52 Wrote:Homework and No Effort Questions
This forum is focused on education. It exists to help people learn Python. We don’t exist to solve others’ problems, although that tends to be a happy byproduct of education.
...
See link for me info
Can you do it with pencil and paper? If not, you cannot write a program to solve the problem. Contact your teacher or classmates to get help understanding the assignment. If you can solve using pencil and paper, write that down as your starting work when you ask for help the next time.