<jupyter_start><jupyter_text>ReviewAdapted from data 8 lab1, lab2, and hw1  Computing walking distancesChunhua is on the corner of 7th Avenue and 42nd Street in Midtown Manhattan, and she wants to know far she'd have to walk to get to Gramercy School on the corner of 10th Avenue and 34th Street.She can't cut across blocks diagonally, since there are buildings in the way.  She has to walk along the sidewalks.  Using the map below, she sees she'd have to walk 3 avenues (long blocks) and 8 streets (short blocks).  In terms of the given numbers, she computed 3 as the difference between 7 and 10, *in absolute value*, and 8 similarly.  Chunhua also knows that blocks in Manhattan are all about 80m by 274m (avenues are farther apart than streets).  So in total, she'd have to walk $(80 \times |42 - 34| + 274 \times |7 - 10|)$ meters to get to the park.**Question** Fill in the line `num_avenues_away = ...` in the next cell so that the cell calculates the distance Chunhua must walk and gives it the name `manhattan_distance`.  Everything else has been filled in for you.  **Use the `abs` function.** Also, be sure to run the test cell afterward to test your code.<!--BEGIN QUESTIONname: q4_1_1--><jupyter_code># Here's the number of streets away:
num_streets_away = abs(42-34)

# Compute the number of avenues away in a similar way:
num_avenues_away = ...

street_length_m = 80
avenue_length_m = 274

# Now we compute the total distance Chunhua must walk.
manhattan_distance = street_length_m*num_streets_away + avenue_length_m*num_avenues_away

# We've included this line so that you see the distance you've computed 
# when you run this cell.  
# You don't need to change it, but you can if you want.
manhattan_distance<jupyter_output><empty_output><jupyter_text>Multiple argumentsSome functions take multiple arguments, separated by commas. For example, the built-in `max` function returns the maximum argument passed to it.<jupyter_code>max(2, -3, 4, -5)<jupyter_output><empty_output><jupyter_text>Understanding nested expressionsFunction calls and arithmetic expressions can themselves contain expressions.  You saw an example in the last question:    abs(42-34)has 2 number expressions in a subtraction expression in a function call expression.  And you probably wrote something like `abs(7-10)` to compute `num_avenues_away`.Nested expressions can turn into complicated-looking code. However, the way in which complicated expressions break down is very regular.Suppose we are interested in heights that are very unusual.  We'll say that a height is unusual to the extent that it's far away on the number line from the average human height.  [An estimate](http://press.endocrine.org/doi/full/10.1210/jcem.86.9.7875?ck=nck&) of the average adult human height (averaging, we hope, over all humans on Earth today) is 1.688 meters.So if Kayla is 1.21 meters tall, then her height is $|1.21 - 1.688|$, or $.478$, meters away from the average.  Here's a picture of that:And here's how we'd write that in one line of Python code:<jupyter_code>abs(1.21 - 1.688)<jupyter_output><empty_output><jupyter_text>What's going on here?  `abs` takes just one argument, so the stuff inside the parentheses is all part of that *single argument*.  Specifically, the argument is the value of the expression `1.21 - 1.688`.  The value of that expression is `-.478`.  That value is the argument to `abs`.  The absolute value of that is `.478`, so `.478` is the value of the full expression `abs(1.21 - 1.688)`.Picture simplifying the expression in several steps:1. `abs(1.21 - 1.688)`2. `abs(-.478)`3. `.478`In fact, that's basically what Python does to compute the value of the expression. **Question** Say that Paola's height is 1.76 meters.  In the next cell, use `abs` to compute the absolute value of the difference between Paola's height and the average human height.  Give that value the name `paola_distance_from_average_m`.<!--BEGIN QUESTIONname: q51-->  Differences between Majors Berkeley’s Office of Planning and Analysis provides data on numerous aspects of the campus. Adapted from the OPA website, the table below displays the numbers of degree recipients in three majors in the academic years 2008-2009 and 2017-2018.| Major                              | 2008-2009    | 2017-2018   ||------------------------------------|--------------|-------------|| Gender and Women's Studies         |      17      |    28       || Linguistics                        |      49      |    67       || Rhetoric                           |      113     |    56       | **Question 1.** Suppose you want to find the **biggest** absolute difference between the numbers of degree recipients in the two years, among the three majors.In the cell below, compute this value and call it `biggest_change`. Use a single expression (a single line of code) to compute the answer. Let Python perform all the arithmetic (like subtracting 49 from 67) rather than simplifying the expression yourself. The built-in `abs` function takes a numerical input and returns the absolute value. The built-in `max` function can take in 3 arguments and returns the maximum of the three numbers<jupyter_code>biggest_change = ...
biggest_change<jupyter_output><empty_output><jupyter_text>**Question 2.** Which of the three majors had the **smallest** absolute difference? Assign `smallest_change_major` to 1, 2, or 3 where each number corresponds to the following major:1: Gender and Women's Studies  2: Linguistics  3: RhetoricChoose the number that corresponds to the major with the smallest absolute difference.You should be able to answer by rough mental arithmetic, without having to calculate the exact value for each major.<jupyter_code>smallest_change_major = ...
smallest_change_major<jupyter_output><empty_output><jupyter_text>**Question 3.**  For each major, define the “relative change” to be the following: $\large{\frac{\text{absolute difference}}{\text{value in 2008-2009}} * 100}$ Fill in the code below such that `gws_relative_change`, `linguistics_relative_change` and `rhetoric_relative_change` are assigned to the relative changes for their respective majors.<jupyter_code>gws_relative_change = (abs(...) / 17) * 100
linguistics_relative_change = ...
rhetoric_relative_change = ...
gws_relative_change, linguistics_relative_change, rhetoric_relative_change<jupyter_output><empty_output><jupyter_text>**Question 4.** Assign `biggest_rel_change_major` to 1, 2, or 3 where each number corresponds to to the following: 1: Gender and Women's Studies  2: Linguistics  3: RhetoricChoose the number that corresponds to the major with the biggest relative change.<jupyter_code># Assign biggest_rel_change_major to the number corresponding to the major with the biggest relative change.
biggest_rel_change_major = ...
biggest_rel_change_major<jupyter_output><empty_output><jupyter_text>1. Review: The building blocks of Python codeThe two building blocks of Python code are *expressions* and *statements*.  An **expression** is a piece of code that* is self-contained, meaning it would make sense to write it on a line by itself, and* usually evaluates to a value.Here are two expressions that both evaluate to 3:    3    5 - 2    One important type of expression is the **call expression**. A call expression begins with the name of a function and is followed by the argument(s) of that function in parentheses. The function returns some value, based on its arguments. Some important mathematical functions are listed below.| Function | Description                                                   ||----------|---------------------------------------------------------------|| `abs`      | Returns the absolute value of its argument                    || `max`      | Returns the maximum of all its arguments                      || `min`      | Returns the minimum of all its arguments                      || `pow`      | Raises its first argument to the power of its second argument || `round`    | Rounds its argument to the nearest integer                     |Here are two call expressions that both evaluate to 3:    abs(2 - 5)    max(round(2.8), min(pow(2, 10), -1 * pow(2, 10)))The expression `2 - 5` and the two call expressions given above are examples of **compound expressions**, meaning that they are actually combinations of several smaller expressions.  `2 - 5` combines the expressions `2` and `5` by subtraction.  In this case, `2` and `5` are called **subexpressions** because they're expressions that are part of a larger expression.A **statement** is a whole line of code.  Some statements are just expressions.  The expressions listed above are examples.Other statements *make something happen* rather than *having a value*. For example, an **assignment statement** assigns a value to a name. A good way to think about this is that we're **evaluating the right-hand side** of the equals sign and **assigning it to the left-hand side**. Here are some assignment statements:        height = 1.3    the_number_five = abs(-5)    absolute_height_difference = abs(height - 1.688)An important idea in programming is that large, interesting things can be built by combining many simple, uninteresting things.  The key to understanding a complicated piece of code is breaking it down into its simple components.For example, a lot is going on in the last statement above, but it's really just a combination of a few things.  This picture describes what's going on. **Question 1.1.** In the next cell, assign the name `new_year` to the larger number among the following two numbers:1. the **absolute value** of $2^{5}-2^{11}-2^1 + 1$, and 2. $5 \times 13 \times 31 + 5$.Try to use just one statement (one line of code). Be sure to check your work by executing the test cell afterward.<jupyter_code>new_year = ...
new_year<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08576660901414182, 'fraction_numerical': 0.027673211923898666, 'mean_word_length': 3.762596899224806, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '415928', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2768, 'n_tokens_neox': 2496, 'n_words': 1291, 'path': 'Week_4/Review/Review.ipynb', 'repo_name': 'ds-modules/BUDS-SU21-Dev', 'size': '9829'}