Chapter 2: Hello, Python (Solutions to Even-Numbered Exercises)

Question 2

+ does not negate a positive number, and so it probably should not negate a negative one. The Python behavior is to leave the sign alone.

Question 4

>>> x = 10.5
>>> y = 4
>>> x = x + y
>>> x
14.5
>>> y
4

Question 6

One of the main problems with "fahrenheit_to_celsius" is that it is quite hard to type, and hard to remember the spelling. "fahr_to_cel" and "fahr_to_celsius" are quite a bit easier. We dislike "f2c" because it uses the colloquial "2" instead of "to" (which is harder for non-native English speakers to recognize) and also because it just isn't expressive enough. "to_celsius" at least conveys that we are working in the temperature domain, and by far the second-most-used temperature scale is Fahrenheit.

Question 8

A parameter is a variable that appears between the parentheses of a function definition. It is assigned a value when the function is called. An argument is an expression that appears between the parentheses of a function call; the value of that expression is assigned to the corresponding parameter.

Question 10

>>> pow(3, 7)
2187
>>> int(34.7)
34
>>> round(34.7)
35.0
>>> int(round(34.7))
35
>>> float(abs(-86))
86.0