HW07: Units#

Purposes of this assignment is to get more practice with the following:

  • For loops

  • Units

  • Function Calls

Problem 1#

Write a function to calculate the time required to fall to the ground for an object given its initial height. The function should take the initial height as a parameter and return the time it takes to fall to the ground. The function should use the following formula that assumes an initial velocity of 0:

\[ t = \sqrt{\frac{2h}{g}} \]

where \(h\) is the initial height, \(g\) is the acceleration due to gravity, and \(t\) is the time.

First write the function and then use it to calculate the time (seconds) it takes to fall from the following heights:

  • 1000 meters

  • 100 meters

  • 10 meters

  • 3281 feet

  • 328.1 feet

  • 32.81 feet

Write the two version of the code to preform the above task: once in SI units and once in English units. The function must take the inputs as given above and return the time in seconds.

Problem 2#

Write a function to calculate the work performed when moving an object of mass m up an incline of a given angle for a given distance. The function should take the mass, angle, and distance as parameters and return the work (ignoring friction). The function should use the following formula:

\[ W = mgd\sin\theta \]

where \(m\) is the mass of the object (assume 10 kilograms or 22 pounds), \(g\) is the acceleration due to gravity, \(d\) is the distance, \(\theta\) is the angle, and \(W\) is the work.

First write the function and then use it to calculate the work required for the following conditions:

  • 1.1 radians and a distance of 3 meters

  • 1.4 radians and a distance of 10 meters

  • 1.45 radians and a distance of 20 meters

  • 63 degrees and a distance of 9.8 feet

  • 80.2 degrees and a distance of 32.81 feet

  • 83.1 degrees and a distance of 65.62 feet

Write the two version of the code to preform the above task: once in SI units and once in English units. The function must take the inputs as given above and return the work in Joules or foot-pounds. For the English unit conditions, include a conversion back to Joules after the function call.

Problem 3#

Write a function to calculate the volume of a cylinder given the diameter and height that includes round off error where the height is truncated to one digit. Determine the error from the trucation by comparing the volume calculated with the truncated height to the volume calculated with the untruncated height. The function should take the diameter and height as parameters and return the volume.