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
aniked [119]
3 years ago
12

The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and eac

h line contains the number of steps taken during a day. (The first line is the number of steps taken on January 1st, the second line is the number of steps taken on January 2nd, and so forth.) Write a program that reads the file, then displays the average number of steps taken for each month. (The data is from a year that was not a leap year, so February has 28 days.)
Computers and Technology
1 answer:
Bumek [7]3 years ago
8 0

Answer:

In Python:

file = open('steps.txt', 'r')

readLine = file.readlines()

begin = 0

mdays = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

print("Month"+"\t\t"+"Average Steps")

for m in range(len(mdays)):

end = begin + mdays[m]

steps = readLine[begin:end]

sumsteps = 0

for s in steps:

 sumsteps = sumsteps + int(s)

 

average = round(sumsteps/mdays[m],1)

print(str(m+1)+"\t\t"+str(average))

begin = begin + mdays[m]

Explanation:

This line opens the step.txt file

file = open('steps.txt', 'r')

This reads the content of the file

readLine = file.readlines()

begin = 0

This initializes the months of the days to a tuple

Mmdays = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

This prints the header

print("Month"+"\t\t"+"Average Steps")

This iterates through the tuple

for m in range(len(Mmdays)):

This calculates the days in each month

end = begin + Mmdays[m]

This gets the number of steps in each month

steps = readLine[begin:end]

This initializes the number of steps to 0

sumsteps = 0

This iteration sums up the number of steps in each month

<em> for s in steps: </em>

<em>  sumsteps = sumsteps + int(s) </em>

This calculates the average of steps rounded to 1 decimal place  

average = round(sumsteps/Mmdays[m],1)

This prints the calculated average

print(str(m+1)+"\t\t"+str(average))

This calculates the beginning of the new month

begin = begin + Mmdays[m]

You might be interested in
The author of ""Cyber-psychopathy: What Goes On in a Hacker’s Head"" claims that the act of hacking is a deep-seated psychologic
lisov135 [29]

Answer:

Explanation:

Based on the information provided within the question it can be said that the text that supports this is that in the book it states that this disorder is due to an obvious "addiction" to the sheer thrill of hacking, born of having found ways around the supposed ingenuity of "invulnerable" cyber security defences.

5 0
3 years ago
Read 2 more answers
Which of the following types of servers can be used to cache requested Internet resources so that they can be more quickly deliv
omeli [17]

Answer:

Proxy Server

Explanation:

  • Proxy server is a server that acts as a mediator between two systems.
  • One system can be your computer and the other can be the server to which you are asking a service, such as requesting a web page.
  • Lets suppose you request a web page from a server and you type a URL of a website to access a web page.
  • This request goes to proxy server which sends this request on your behalf to the target server in order to retrieve that web page.
  • Proxy server makes this request to the target server on the internet by using one of its IP addresses.
  • When the proxy server gets that web page, it will forward that web page to your requesting computer.
  • If you request a specific service such as a website frequently the proxy server saves that website on its cache.
  • So if you request that website again, proxy server will forward it to you from its cache rather than requesting it again from the target server on your behalf resulting in quick response to the user's request. This speeds up the delivery of resources to the users.
  • Proxy servers provide users with privacy to access the websites, and they can surf the internet anonymously .
8 0
3 years ago
Information posted online can be deleted in some cases, but why would it be difficult to know if it is really gone?
lidiya [134]

Answer:

b

I need I Brainliest

5 0
2 years ago
The major difference between a template and another document is in.​
tensa zangetsu [6.8K]
Templates in pandadoc are used for generic content that you intend on using multiple times, while documents are used for specific information. In order to send a document, you must first creat it from an existing template.
4 0
3 years ago
In case of an emergency, once you or someone already on the scene has contacted 9-1-1, the next thing to do is: A) Move them to
velikii [3]

if alone, you would give care first for which situation

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is PHP language
    12·1 answer
  • Tim has an old server computer that his company uses as a backup. One of the hard drives has gone bad and needs to be replaced.
    14·1 answer
  • Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    12·2 answers
  • Which was the first wiki based website
    15·2 answers
  • What uses HTML hypertext links that users can click to access different locations or information?
    11·1 answer
  • Which of the following is generally nota desire today's workers? A. computer ability B willingness to learn C. teamwork skills D
    8·1 answer
  • In a _____ cloud, a participating organization purchases and maintains the software and infrastructure itself.
    10·1 answer
  • A client is
    15·2 answers
  • In which of the following phases of filmmaking would a production team be focused on the process of casting?
    11·2 answers
  • How would you assign roles to your group members?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!