File tree 2 files changed +15
-15
lines changed 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -5,17 +5,17 @@ def celsius_to_fahrenheit(celsius):
5
5
"""
6
6
Convert a given value from Celsius to Fahrenheit
7
7
8
- >>> celsius_to_fahrenheit(-40)
8
+ >>> print( celsius_to_fahrenheit(-40) )
9
9
-40.0
10
- >>> celsius_to_fahrenheit(-20)
10
+ >>> print( celsius_to_fahrenheit(-20) )
11
11
-4.0
12
- >>> celsius_to_fahrenheit(0)
12
+ >>> print( celsius_to_fahrenheit(0) )
13
13
32.0
14
- >>> celsius_to_fahrenheit(20)
14
+ >>> print( celsius_to_fahrenheit(20) )
15
15
68.0
16
- >>> celsius_to_fahrenheit(40)
16
+ >>> print( celsius_to_fahrenheit(40) )
17
17
104.0
18
- >>> celsius_to_fahrenheit("40")
18
+ >>> print( celsius_to_fahrenheit("40") )
19
19
Traceback (most recent call last):
20
20
...
21
21
TypeError: 'str' object cannot be interpreted as integer
@@ -28,7 +28,7 @@ def celsius_to_fahrenheit(celsius):
28
28
raise TypeError ("'str' object cannot be interpreted as integer" )
29
29
30
30
fahrenheit = (celsius * 9 / 5 ) + 32 # value converted from celsius to fahrenheit
31
- print ( fahrenheit )
31
+ return fahrenheit
32
32
33
33
34
34
if __name__ == "__main__" :
Original file line number Diff line number Diff line change 3
3
4
4
def fahrenheit_to_celsius (fahrenheit ):
5
5
"""
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 .
7
7
8
- >>> fahrenheit_to_celsius(0)
8
+ >>> print( fahrenheit_to_celsius(0) )
9
9
-17.78
10
- >>> fahrenheit_to_celsius(20)
10
+ >>> print( fahrenheit_to_celsius(20) )
11
11
-6.67
12
- >>> fahrenheit_to_celsius(40)
12
+ >>> print( fahrenheit_to_celsius(40) )
13
13
4.44
14
- >>> fahrenheit_to_celsius(60)
14
+ >>> print( fahrenheit_to_celsius(60) )
15
15
15.56
16
- >>> fahrenheit_to_celsius(80)
16
+ >>> print( fahrenheit_to_celsius(80) )
17
17
26.67
18
- >>> fahrenheit_to_celsius(100)
18
+ >>> print( fahrenheit_to_celsius(100) )
19
19
37.78
20
- >>> fahrenheit_to_celsius("100")
20
+ >>> print( fahrenheit_to_celsius("100") )
21
21
Traceback (most recent call last):
22
22
...
23
23
TypeError: 'str' object cannot be interpreted as integer
You can’t perform that action at this time.
0 commit comments