1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Yuliya22 [10]
3 years ago
13

Write a function maxTemp which takes a filename as string argument and returns the maximum temperature as float type for the wee

k. Input file will contain temperature readings for each day of the week. Your function should read each line from the given filename, parse and process the data, and return the required information. Your function should return the highest temperature for the whole week. Empty lines do not count as entries, and should be ignored. If the input file cannot be opened, return -1. Remember temperature readings can be decimal and negative numbers. Each line of the file contains two elements, separated by commas (,) DAY,TEMPERATURE Monday,52 Note: The split() function is provided, and functions as it does in the homework assignments, to make parsing the output easier. Recall that split takes a string s and splits it at the input delimiter sep, to fill the array words[] up to a capacity of max_words. The return value of split is the number of actual words the string is split into.

Computers and Technology
1 answer:
Alenkinab [10]3 years ago
8 0

Answer:

#section 1

def maxTemp(filename):

   import pathlib

   f = pathlib.Path(filename)

   f.exists()

   if f.exists():

       f = open(filename, "r")

#section 2

       next(f)

       res = [int(sub.split(',')[1]) for sub in f]

       maxdata = (res[0])

       for i in range(len(res)-1):

           if maxdata < res[i]:

               maxdata = res[i]

       

       index = res.index(maxdata)

       f.close()

 #section 3  

       li = []  

       a = open(filename, "r")

       for line in a:

           line = line.strip()

           li.append(line)

   

       

       a.close()

       return (li[index+1])

   else:

       return -1

print(maxTemp("new.csv"))

Explanation:

#section 1:

The function maxTemp is defined. We import pathlib in other to check if the file exists, if it does we carry on with opening the file and if it doesn't the program returns -1.

#section 2:

We start splitting the sub-lists from the second line i.e <em>next(f)</em>. For each line we take the second index element and convert it to an integer.

<em>res = [int(sub.split(',')[1]) for sub in f] </em>

The maximum number is gotten by using the if statement to compare all elements in the list.  The index of the maximum item in the list is collected.

the file is then closed.

#section 3  :

The file is re-opened and all the lines are striped and passed into a new list and the index recovered from section 2, is used to get the day with the highest temperature and the line is returned.

You might be interested in
What acronym describes networked devices that contain microcomputers but are not thought of as computing devices, such as refrig
vivado [14]
The acronym RFID (Radio Frequency Identification) describes networked devices that contain microcomputers but are not thought of as computing devices, such as refrigerators, automobile components, light bulbs, and industrial control devices. RFIDs are  battery-powered sensors that gather and transmit data to a reading device. Some sensor based technologies are  scanning electron microscopes, LiDAR,radar, GPS, x-ray, sonar, infrared and seismic.



5 0
3 years ago
Consider the following import statement in Python, where statsmodels module is called in order to use the proportions_ztest meth
den301095 [7]

Answer:

a. count of observations that meet a condition (counts), total number of observations (nobs), Hypothesized value of population proportion (value).

Explanation:

In other to use the proportion_ztest method, the need to make import from the statsmodel module ; statsmodels.stats.proportion.proportions_ztest ; this will allow use use the Z test for proportion and once this method is called it will require the following arguments (count, nobs, value=None, alternative='two-sided', prop_var=False)

Where;

nobs = number of observations

count = number of successes in the nobs trial or the number of successes for each independent sample.

Value = hypothesized value of the population proportion.

7 0
3 years ago
if you want to present slides to fellow students and co-workers which productivity software should you use to create them?
ladessa [460]

Answer:

Microsoft PowerPoint.

Explanation:

Because, it is industry standard and widely recognized and used in world.

8 0
2 years ago
An excel worksheet can have a maximum of ____ columns in a worksheet.
Marina CMI [18]

It can have only 16,384 number of columns

6 0
3 years ago
NTDS Quotas store NT Directory Service quota information that limits the number of Active Directory objects a user, group, compu
Anna35 [415]

Answer:

The anwer is advanced feature folder

Explanation:

Because NTDS QUOTAS is an advanced feature folder that stores NTDS quota information that limits the number of Active Directory objects a user, group, computer, or service can create.

3 0
3 years ago
Other questions:
  • When it comes to safety, the choice to be safe is often up to __________?
    8·1 answer
  • How to know if somebody else is listening my conversations by cellphone?
    13·1 answer
  • What are attribute grammars used for?
    8·1 answer
  • What devices gives input​
    5·1 answer
  • Why was the cooper black font made?
    5·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • What output is generated by this for loop?
    6·1 answer
  • design a relational database in EER for bike helmets and their reviews. a bike helmet has a name and color attributes. a bike co
    12·1 answer
  • View which is used to specify the tables fields , their data types and properties ​
    9·2 answers
  • Write a short-essay discussing your own stand on social media usage for students.​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!