Question: Write a Python function that takes two parameters: distance ( in kilometres ) and weight ( in kilograms ) . The function should calculate and

Write a Python function that takes two parameters: distance (in kilometres) and weight (in kilograms). The function should calculate and return the shipping cost based on the following criteria:
For distances less than or equal to 50 kilometres, the shipping cost is R.O.5 per kilogram.
For distances greater than 50 kilometres, the shipping cost is R.O.7 per kilogram.
Write a main function to test the defined function by prompting the user to input the distance. Then, randomly generate the weight of the package (between 5 and 100 kg). Finally, call the defined function above with these inputs and print the total shipping cost.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!