generated from geo-python-2019/Exercise-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp_functions.py
38 lines (29 loc) · 1.12 KB
/
temp_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
""""Script file to store temperature functions
Contains two functions for converting and classifying temperatures
Author:
Jorjito the magnificent
"""
"""Converts farenheit temperatures into celsius
Parameters:
requires temperature values in fahrenheit
Returns:
temperature value in celsius
"""
def fahr_to_celsius(temp_fahrenheit): # code takes a single variable, can be a float or an integer
converted_temp = (temp_fahrenheit - 32)/1.8
return converted_temp # returns a number
""" Classifies temperatures into one of four values
Takes temperature in celsius as its only parameter
Returns an integer based on the value of the temperature input
"""
def temp_classifier(temp_celsius): # define your functions name and input parameter
# set the ranges of values which specify how they are classified
if temp_celsius < -2:
category = 0
elif temp_celsius >= -2 and temp_celsius < 2: # cannot use the '&' symbol for some reason
category = 1
elif temp_celsius >= 2 and temp_celsius < 15:
category = 2
elif temp_celsius >= 15:
category = 3
return category