Skip to content

Commit 2c151fa

Browse files
authored
Merge pull request #1029 from SalenaAshton/patch-1
Beginner-friendly function composition
2 parents a1256c1 + 82d0b84 commit 2c151fa

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

_episodes/08-func.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ Let's start by defining a function `fahr_to_celsius` that converts temperatures
5050
from Fahrenheit to Celsius:
5151

5252
~~~
53+
def explicit_fahr_to_celsius(temp):
54+
# Assign the converted value to a variable
55+
converted = ((temp - 32) * (5/9))
56+
# Return the value of the new variable
57+
return converted
58+
5359
def fahr_to_celsius(temp):
60+
# Return converted value more efficiently using the return
61+
# function without creating a new variable. This code does
62+
# the same thing as the previous function but it is more explicit
63+
# in explaining how the return command works.
5464
return ((temp - 32) * (5/9))
5565
~~~
5666
{: .language-python}

0 commit comments

Comments
 (0)