Example adityaheightm becomes 478 Repeat We continue

# Example adityaheightm becomes 478 repeat we continue

This preview shows page 15 - 18 out of 18 pages.

(Example: aditya_height_m - average_adult_human_height_m becomes -.478 .) * Repeat: We continue this process, using the values of the glommed-together stuff as our new basic compo- nents. (Example: abs(-.478) becomes .478 , and max(.478, .162) later becomes .478 .) * We keep doing that until we’ve evaluated the whole expression. You can run the next cell to see a slideshow of that process. In [55]: from IPython.display import IFrame IFrame( ' 15
Out[55]: <IPython.lib.display.IFrame at 0x7f75f80e6128> Ok, your turn. Question 5.1.1. Given the heights of the Splash Triplets from the Golden State Warriors, write an expression that computes the smallest difference between any of the three heights. Your ex- pression shouldn’t have any numbers in it, only function calls and the names klay , steph , and kevin . Give the value of your expression the name min_height_difference . In [62]: # The three players ' heights, in meters: klay = 2.01 # Klay Thompson is 6 ' 7" steph = 1.91 # Steph Curry is 6 ' 3" kevin = 2.06 # Kevin Durant is officially 6 ' 9", but many suspect that he is taller. # (Further complicating matters, membership of the "Splash Triplets" # is disputed, since it was originally used in reference to # Klay Thompson, Steph Curry, and Draymond Green.) # We ' d like to look at all 3 pairs of heights, compute the absolute # difference between each pair, and then find the smallest of those # 3 absolute differences. This is left to you! If you ' re stuck, # try computing the value for each step of the process (like the # difference between Klay ' s heigh and Steph ' s height) on a separate # line and giving it a name (like klay_steph_height_diff). min_height_difference = min ( abs (klay - steph), abs (klay - kevin), abs (steph - kevin)) In [63]: _ = ok . grade( ' q511 ' ) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed You’re done with Lab 1! Be sure to run the tests and verify that they all pass, then choose Save and Checkpoint from the File menu, then run the final cell (two below this one) to submit your work. If you submit multiple times, your last submission will be counted. In [64]: # For your convenience, you can run this cell to run all the tests at once! import os _ = [ok . grade(q[: -3 ]) for q in os . listdir( "tests" ) if q . startswith( ' q ' )] _ = ok . submit() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests 16
--------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 3 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 4 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 4 Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 5 17
Failed: 0 [ooooooooook] 100.0% passed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 3 Failed: 0 [ooooooooook] 100.0% passed <IPython.core.display.Javascript object> <IPython.core.display.Javascript object> Saving notebook... Saved ' lab01.ipynb ' .

#### You've reached the end of your free preview.

Want to read all 18 pages?

• Fall '17
• Human height

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern