Skip to content

Commit e1673ef

Browse files
committed
changed the code to let the caller do the printing
1 parent ff16a89 commit e1673ef

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

conversions/celsius_to_fahrenheit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ def celsius_to_fahrenheit(celsius):
55
"""
66
Convert a given value from Celsius to Fahrenheit
77
8-
>>> celsius_to_fahrenheit(-40)
8+
>>> print(celsius_to_fahrenheit(-40))
99
-40.0
10-
>>> celsius_to_fahrenheit(-20)
10+
>>> print(celsius_to_fahrenheit(-20))
1111
-4.0
12-
>>> celsius_to_fahrenheit(0)
12+
>>> print(celsius_to_fahrenheit(0))
1313
32.0
14-
>>> celsius_to_fahrenheit(20)
14+
>>> print(celsius_to_fahrenheit(20))
1515
68.0
16-
>>> celsius_to_fahrenheit(40)
16+
>>> print(celsius_to_fahrenheit(40))
1717
104.0
18-
>>> celsius_to_fahrenheit("40")
18+
>>> print(celsius_to_fahrenheit("40"))
1919
Traceback (most recent call last):
2020
...
2121
TypeError: 'str' object cannot be interpreted as integer
@@ -28,7 +28,7 @@ def celsius_to_fahrenheit(celsius):
2828
raise TypeError("'str' object cannot be interpreted as integer")
2929

3030
fahrenheit = (celsius * 9 / 5) + 32 # value converted from celsius to fahrenheit
31-
print(fahrenheit)
31+
return fahrenheit
3232

3333

3434
if __name__ == "__main__":

conversions/fahrenheit_to_celsius.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33

44
def fahrenheit_to_celsius(fahrenheit):
55
"""
6-
Convert a given value from Fahrenheit to Celsius and round it to 2 d.p.
6+
Convert a given value from Fahrenheit to Celsius and round it to 2 decimal places.
77
8-
>>> fahrenheit_to_celsius(0)
8+
>>> print(fahrenheit_to_celsius(0))
99
-17.78
10-
>>> fahrenheit_to_celsius(20)
10+
>>> print(fahrenheit_to_celsius(20))
1111
-6.67
12-
>>> fahrenheit_to_celsius(40)
12+
>>> print(fahrenheit_to_celsius(40))
1313
4.44
14-
>>> fahrenheit_to_celsius(60)
14+
>>> print(fahrenheit_to_celsius(60))
1515
15.56
16-
>>> fahrenheit_to_celsius(80)
16+
>>> print(fahrenheit_to_celsius(80))
1717
26.67
18-
>>> fahrenheit_to_celsius(100)
18+
>>> print(fahrenheit_to_celsius(100))
1919
37.78
20-
>>> fahrenheit_to_celsius("100")
20+
>>> print(fahrenheit_to_celsius("100"))
2121
Traceback (most recent call last):
2222
...
2323
TypeError: 'str' object cannot be interpreted as integer

0 commit comments

Comments
 (0)