Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The file for plant _ data looks something like the picture shown. Write this code in python. table [ [ , A , B
The file for plantdata looks something like the picture shown. Write this code in python.
tableAG#use the csv library to read Atmosphere Temperature, Soil Temperature, Atmosphere Humidity and Soil Humidity from PlantData.csv Don't forget to close your file at the end!
#Create a function to read each variable into a dictionary using the csvDictReader function
#Inside of that same function, use a for loop to append each of the value pairs for each category to an empty list
#Pass these lists to another function that will calculate the averages if the values in each list Hint: Make sure your data is the correct data type
#Use the function to return these averages to the main Display the average values inside main with digit precision.
import csv
from statistics import mean
def readtolist:
#### Fix Me ####
with openPATH TO DATA' as csvfile:
#create dictionary with key value pairs foratm tep, atm hum, soil hum and soil temp
reader csvDictReadercsvfile
#create empty lists for values for each month key value pairs
atmtempavg
soiltempavg
atmhumavg
soilhumavg
#append each value pair of dictionary to list
for i in reader:
#### Fix Me ####
#### Fix Me ####
return
def calcavgs:
#convert hum and temp values to floats
averageatmtemp
averagesoiltemp
averageatmhum
averagesoilhum
#convert hum and temp values to floats
#averageatmtemp meanmapfloat atmtempavg
for j in at:
averageatmtemp
averageatmtemp lenat
#### Fix Me ####
for
#### Fix Me ####
for...???
#### Fix Me ####
for...???
#### Fix Me ####
return
# Main function
def main:
#### Fix Me ####
readtolist
calcavgs
#show total averages
#### Fix Me ####
print
print
print
print
#call main to kick it off
#### Fix Me ####
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started