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
Which icon is greater in file size? (Show your working)
nadya68 [22]

Answer:

the 256 color icon would be greater in file size.

Explanation:

regardless of how many pixels are in the image, file A has 256 colors meaning the computer has to individually load each one of those colors. it'll probably use a lot of ink if you decide to print it, too.

5 0
3 years ago
When would it be necessary to edit the information shown on an electronic business card?
Goryan [66]

Answer:

Really depends on your situation. If you specified, I'd have an asnwer

3 0
3 years ago
Read 2 more answers
1. Write a static method named computeOddSum that is passed an array of int's named numbers. The method must compute and return
S_A_V [24]

Answer:

The method in Java is as follows:

public static int computeOddSum(int [] myarray){

       int oddsum = 0;

       for(int i=0; i<myarray.length; i++ ) {

        if(myarray[i]%2==1) {

           oddsum+=myarray[i];

        }

     }

     return oddsum;

   }

Explanation:

This defines the static method

public static int computeOddSum(int [] myarray){

This initializes oddsum to 0

       int oddsum = 0;

This iterates through the array

       for(int i=0; i<myarray.length; i++ ) {

This checks for odd number

        if(myarray[i]%2==1) {

The odd numbers are added, here

           oddsum+=myarray[i];

        }

     }

This returns the calculated sum of odd numbers

     return oddsum;

   }

To call the method from main, use:

<em>int [] myarray = {3, 10, 11, 2, 6, 9, 5};</em>

<em>      System.out.println("Odd sum = " + computeOddSum(myarray));</em>

5 0
2 years ago
This is the question
nikdorinn [45]

Answer:

I dont know it sorry

Explanation:

i would help u

4 0
2 years ago
What does it mean to design,<br> implement, and maintain computer<br> systems?
docker41 [41]

Answer:

Let's take an example of the embedded system, which is a perfect example of this question as a computer system. Suppose we want the embedded system to record the details related to soil of agricultural land. We will take an IoT device which will be a sensor that can register soil properties, and get connected to the computer system through the internet. And we design an embedded system that registers these values and then copy them like somewhere in DB space on Amazon cloud or Google cloud. And finally display on some LCD or a big projector, or whatever, and like we design. Thus we have designed, and now when we install this on agriculture land, we implement it, and since check regular for correct performance, we maintain this embedded or a mini-computer system as well. This is what design, implement and maintain computer systems mean.

Explanation:

Please check the answer section.

8 0
3 years ago
Other questions:
  • Abram was asked to explain to one of his coworkers the XOR cipher. He showed his coworker an example of adding two bits, 1 and 1
    7·1 answer
  • One gigabyte can be expressed as: a.) 1,000 kilobytes b.) 1,000 bytes c.) 80,000 kilobytes d.) 1,000 megabytes e.) 8,000 bits
    5·1 answer
  • In the view that follows, which field can't be updated create view example_2 as select invoice_number, invoice_date, invoice_tot
    13·1 answer
  • I’m turning my Pinterest into a professional account what should be my user name please try to think of a good name and not just
    11·2 answers
  • Any executable files???
    5·1 answer
  • Two types of formulas in Excel, what are they? A. Complex and simple, B. General and currency, C. Logical and Boolean, D. Trig a
    15·1 answer
  • The first known permanent photograph was called "View from the Window at Le Gras." True False
    9·1 answer
  • To configure a router/modem, what type of IP interface configuration should you apply to the computer you are using to access th
    10·1 answer
  • Can someone follow my tt its c1ndy.dont.miss
    6·1 answer
  • One of 34 possible _________________ can be assigned to each axis of classification in the seven-character code.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!