Due Date: Friday February 12, midnight
Submit your individual file (hw3.py) with the Canvas link.
Reminder that "Individual" means that you should not talk to another student in the class about it. You ARE encouraged to talk to any TA or your lecturer.
Educational goals of this lab - verify that every student can
INSTRUCTIONS:
Scientists studying a forest ecosystem over a long period of time may record measurements of trees for a number of variables, including each tree's diameter at breast height, height of the lowest living branch, canopy cover, etc. One aspect of a tree's growth that can be hard to measure is tree height. The easiest way to find the height is using a trigonometric function. If you know the distance you are from the foot of the tree, the angle that the top of the tree makes from the ground (your eye) (angle of elevation), and your height from the ground to your eye level, you can calculate the height of the tree.
Put the answers that go in the blanks below into a triple-quoted comment at the bottom of the program file. It should be the expected output (height) from the above program, given the inputs in the case. Use a calculator as needed. Note that you will have to put the calculator in "degrees" mode. For each test case, you get two points for getting the correct answer by hand, and 1 point for your program running it correctly.
Description | Inputs Angle of Elevation (deg), distance to tree (ft) height of observer to eyes (ft) | Expected Output Height (ft) |
---|---|---|
Normal case, integers | 45, 50, 5 | ____A.____ |
Normal case, floats | 75.0, 92.5, 4.9 | ____B.____ |
Point of view at base of tree | 89.5, 0, 5.1 | ____C.____ |
Negative angle | -10.0, 100, 5.2 | ____D.___ |
# Purpose: # Pre-cond: # Post-cond: # use math library for radians function needed to convert input angle to radians # and tan function used to calculate height #print title and blank line #get 3 input values, angle of elevation, distance to base and height of observer # COMPLETE the steps needed here # report resulting height, using 2 decimals
Test run 1:
Finding the height of a tree Angle of elevation to top of tree (deg): 49 How far to the base of the tree (ft)? 500 Your height up to your eyes (ft)? 5.1 The height of the tree is 580.28 feet
Test run 2:
Finding the height of a tree Angle of elevation to top of tree (deg): 35.2 How far to the base of the tree (ft)? 30 Your height up to your eyes (ft)? 4.8 The height of the tree is 25.96 feet