Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function calls and arithmetic expressions can themselves contain expressions. You saw an example in the last question: abs ( 42-34 ) has 2 number expressions

Function 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 likeabs(7-10)to computenum_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 estimateof 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.211.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:

abs(1.21 - 1.688)

What's going on here?abstakes just one argument, so the stuff inside the parentheses is all part of thatsingle argument. Specifically, the argument is the value of the expression1.21 - 1.688. The value of that expression is-.478. That value is the argument toabs. The absolute value of that is.478, so.478is the value of the full expressionabs(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.

Say that Paola's height is 1.76 meters. In the next cell, useabsto compute the absolute value of the difference between Paola's height and the average human height. Give that value the namepaola_distance_from_average_m.

# Replace the ... with an expression

# to compute the absolute value

# of the difference between Paola's height (1.76m) and the average human height.

paola_distance_from_average_m = ...

# Again, we've written this here

# so that the distance you compute will get printed

# when you run this cell.

paola_distance_from_average_m

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Ideas Math A Common Core Curriculum Blue

Authors: Ron Larson, Laurie Boswell

1st Edition

1608402282, 978-1608402281

More Books

Students also viewed these Mathematics questions

Question

What is this?

Answered: 1 week ago