CPSC120A
Fundamentals of Computer Science I

Lab 5

Creating Functions

Use the command line to create a new directory called lab5 in your labs directory. Make sure all of the .py files that you create for this activity are in that directory.

Humanitarian Aid

The non-profit humanitarian aid organization Aid Now sends aid packages to people affected by natural disasters. In order to compute how many packages they can afford to ship to a region the organization must calculate shipping costs. Write a program that computes how much it costs to ship one filled cargo container.

In a file called aid.py, create a function called print_shipment_cost, that prints how much one cargo container will cost to ship. The function should prompt the user to enter the length, width, height, and weight of a single humanitarian aid package. The cost to ship one cargo container is 25 cents per pound. An empty cargo ontainer weighs 4,850 pounds. The interior dimensions of a container are 18.75 feet long, 7.75 feet wide, and 7.75 feet high. The aid package contents are fragile and can not be placed on their side, so there are only two different ways to pack the boxes into the container. The function should compute the maximum number of packages that can fit in a cargo container using the built-in (max)[http://docs.python.org/3/library/functions.html#max] function.

BMI

Body Mass Index (BMI) is a measurement devised in the 1800's, as a way of analyzing an individuals body shape, as it relates to their height in weight. While the values and benefits of such analysis is hotly contested, generally speaking a "normal" BMI is in the range 18.5 to 25.

In a file called bmi.py, create a function called print_bmi, for computing BMI using values when given metric values. This function should use prompt the user for a weight, in kilograms, and height, in meters, and print the calculated BMI. The BMI of a person is computed by dividing a person's weight, in kilograms, by the square of the person's height, in meters.

Submission

Please show your source code and run your test cases for the instructor or lab assistant. Only a program that has perfect style, thorough test cases, and flawless functionality will be accepted as complete.