# **You can do the temperature conversion and classification inside one for loop:** # # - Iterate over the list of Fahrenheit temperatures (create a `for` loop), and inside the loop: # # 1. Create a new variable called `temp_celsius` in which you should assign the temperature in Celsius using the `fahr_to_celsius` function to convert the Fahrenheit temperature into Celsius. # 2. Create a new variable called `temp_class` in which you should assign the temperature class number (0, 1, 2, or 3) using the `temp_classifier` function # 3. Add the `temp_class` value to the `temp_classes` list # YOUR CODE HERE #import the two function from temp_functions import fahr_to_celsius, temp_classifier #create empty list temp_classes = [] #convert for temperature in temp_data: temp_celsius = fahr_to_celsius(temperature) temp_class = temp_classifier(temp_celsius) temp_classes.append(temp_class) # #### Part 2 (continues) # # 6. Calculate how many temperatures there are in each temperature class: # # 1. Create four variables called `zeros`, `ones`, `twos`, and `threes` # 2. Count and assign to each variable how many times values 0, 1, 2, and 3 are present in the `temp_classes` list and print out the results below. In other words, assign the value of how many time `0` is in the list to the variable `zeros`, and so on. # # YOUR CODE HERE #create each of them zeros = 0 ones = 0 twos = 0
# # **You can do the temperature conversion and classification inside one for loop:** # # - Iterate over the list of Fahrenheit temperatures (create a `for` loop), and inside the loop: # # 1. Create a new variable called `temp_celsius` in which you should assign the temperature in Celsius using the `fahr_to_celsius` function to convert the Fahrenheit temperature into Celsius. # 2. Create a new variable called `temp_class` in which you should assign the temperature class number (0, 1, 2, or 3) using the `temp_classifier` function # 3. Add the `temp_class` value to the `temp_classes` list # YOUR CODE HERE from temp_functions import fahr_to_celsius,temp_classifier temp_classes=[] for i in temp_data: temp_celsius=fahr_to_celsius(temp_data[i]) temp_class=temp_classifier(temp_celsius) temp_classes.append(temp_class) # #### Part 2 (continues) # # 6. Calculate how many temperatures there are in each temperature class: # # 1. Create four variables called `zeros`, `ones`, `twos`, and `threes` # 2. Count and assign to each variable how many times values 0, 1, 2, and 3 are present in the `temp_classes` list and print out the results below. In other words, assign the value of how many time `0` is in the list to the variable `zeros`, and so on. # # YOUR CODE HERE #Create four variables called zeros, ones, twos, and threes and count and assign to each variable how many times values 0, 1, 2, and 3 are present zeros=temp_classes.count(0) ones=temp_classes.count(1)
# 4. **Convert the Fahrenheit temperatures** in the `temp_data` list into Celsius and **classify the Celsius temperatures** using the importend functions. The output should be stored in the `temp_classes` list # # **You can do the temperature conversion and classification inside one for loop:** # # - Iterate over the list of Fahrenheit temperatures (create a `for` loop), and inside the loop: # # 1. Create a new variable called `temp_celsius` in which you should assign the temperature in Celsius using the `fahr_to_celsius` function to convert the Fahrenheit temperature into Celsius. # 2. Create a new variable called `temp_class` in which you should assign the temperature class number (0, 1, 2, or 3) using the `temp_classifier` function # 3. Add the `temp_class` value to the `temp_classes` list # YOUR CODE HERE import temp_functions temp_classes=[] for x in temp_data: temp_celsius=temp_functions.fahr_to_celsius(x) temp_class=temp_functions.temp_classifier(temp_celsius) temp_classes.append(temp_class) print(temp_classes) # #### Part 2 (continues) # # 6. Calculate how many temperatures there are in each temperature class: # # 1. Create four variables called `zeros`, `ones`, `twos`, and `threes` # 2. Count and assign to each variable how many times values 0, 1, 2, and 3 are present in the `temp_classes` list and print out the results below. In other words, assign the value of how many time `0` is in the list to the variable `zeros`, and so on. # # YOUR CODE HERE zeros=0 ones=1