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 Internet of Things (IoT) is a concept with emphasis on machine-to-machine communications to describe a more complex system t
VLD [36.1K]

Answer:

IoE(Information of Everything)  is the correct answer to the following question.

Explanation:

The following answer is correct because it is the concept that process, data, people and also Internet of Things brings together by which the network connection become more valuable and more compatible as compared to before and also it can extend the IoT(Internet of Things).

So, that's why the following answer is correct.

8 0
3 years ago
Jenis jenis perangkat keras?
Oksanka [162]
Input, output, dan prosess
3 0
3 years ago
Vendors who use open source as part of their product offerings can expect to bring new products to the market faster because: Gr
tamaranim1 [39]

Answer:

A.  they can skip whole segments of the software development process.

Explanation:

A software development process refers to the process of dividing software development work into various phases for product management, project management and to improve the design.

Vendors who use open source as part of their product offerings can expect to bring new products to the market faster because they can skip whole segments of the software development process.

They don't have to go through different phases of software development.

6 0
3 years ago
What time is spellrd the same forwards and backwards​
Juliette [100K]
12:21 is the correct answer
6 0
2 years ago
Both UDP and TCP use port numbers to identify the destination entity when delivering a message. Give at least one reason for why
raketka [301]

Answer:

Follows are the solution to this question:

Explanation:

The process ID is not static because this can't be used to identity, therefore, it includes excellent service providers like HTTP since it is allocated dynamically only to process whenever a process is initiated.

Sometimes its instance connectors are managed on numerous TSAPs. This can be implemented unless the process ID is being used as each procedure could have an identity.

4 0
2 years ago
Other questions:
  • ________ is the abbreviation for the place in the computer where the programs and data the computer is currently using are store
    8·1 answer
  • Which are valid double statements for java? double a = 0; double b = -1.0; double c = -425; double d = 6340; double e = -1.0; do
    12·2 answers
  • Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followe
    13·1 answer
  • Why should you need to have skills and an understanding about programming?
    8·1 answer
  • Convert the following pseudocode to C++ code. Be sure to define the appropriate variables. Store 25 in the speed variable. Store
    5·1 answer
  • What are the pasting options in Outlook 2016? Check all that apply.
    10·2 answers
  • How does the post process alert the user if it detects a hardware problem during the post process?
    6·1 answer
  • Cash cows are always in
    7·1 answer
  • Cable Internet access can be described with which feature?
    5·2 answers
  • The computer components that enables a computer to send and receive data, instructions or information from one or more computers
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!