Renaming Python’s Functions¶
The functions abs
and int
are names. They are variables whose
values are a set of statements that achieve a goal. Later on, we’ll know
enough code to write abs
and int
ourselves. The important point right
now is that abs
and int
are names for functions. You can create
several names that have the same value. You can think of this like how a
person can have both a name and a nickname. In the program below we
demonstrate that you can even create new names for Python functions.
-
csp-6-7-1: If you add one more line to the above program, print(no_decimal(absolute(-16.789))), what prints?
- -16
- No, absolute will change the negative
- -16.789
- No, the original number will change
- 16.789
- No, no_decimal will remove the decimal part
- 16
- Yes! Absolute will make it positive, and no_decimal will throw away the values after the decimal point leaving just the 16.