21.10.2020

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 each 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.)

. 0

Step-by-step answer

24.06.2023, solved by verified expert
Unlock the full answer
1 students found this answer . helpful

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

for s in steps:

 sumsteps = sumsteps + int(s)

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]

It is was helpful?

Faq

Computers and Technology
Step-by-step answer
P Answered by PhD

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

for s in steps:

 sumsteps = sumsteps + int(s)

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]

Computers and Technology
Step-by-step answer
P Answered by Specialist

See explaination for the program code.

Explanation:

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

lines = fh.readlines()

start = 0

days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

print('{:<7s} {:<10s}'.format('Month', 'Average Steps'))

for m in range(12):

end = start + days_in_months[m]

steps = lines[start:end]

avg = 0

for s in steps:

avg = avg + int(s)

avg = avg // len(steps)

print('{:<7d} {:<10d}'.format(m+1, avg))

start = start + days_in_months[m]

Please kindly check attachment for for the program code.


A Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned,
Computers and Technology
Step-by-step answer
P Answered by Specialist

See explaination for the program code.

Explanation:

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

lines = fh.readlines()

start = 0

days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

print('{:<7s} {:<10s}'.format('Month', 'Average Steps'))

for m in range(12):

end = start + days_in_months[m]

steps = lines[start:end]

avg = 0

for s in steps:

avg = avg + int(s)

avg = avg // len(steps)

print('{:<7d} {:<10d}'.format(m+1, avg))

start = start + days_in_months[m]

Please kindly check attachment for for the program code.


A Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned,
Computers and Technology
Step-by-step answer
P Answered by PhD
Answer: c. internet of things.

Explanation:
The technology that combines with the 5G capabilities which was used in the monitoring of the shopping trends is the Internet of Things.
- Internet of Things (IoT) simply means when there are interrelated, and internet-connected objects which collects and transfers data without human intervention through a wireless network or makes use of sensors.
- This is being used by the retailer in the example given to monitor the shopping trends. In conclusion, the correct option is Internet of Things.
Computers and Technology
Step-by-step answer
P Answered by Master

The correct answer to the following question will be "Auto-encoder".

Explanation:

It is indeed a form of artificial neural net that utilizes in an unmonitored way to practice successful information coding.

The objective of such an auto-encoder seems to be to acquire a specification (encoding) for a collection of information, usually for reducing degrees of freedom, by teaching the channel to overlook the "noise" message.Learn a few things of endogenous model representation and then use it to recreate the object.
Computers and Technology
Step-by-step answer
P Answered by PhD

A code in C++ follows:

Explanation:

#include<iostream>

using namespace std;

int calculate_area(int width, int length)

{

int area;

area=width*length;

return area;

}

int main()

{

int a,b,ar,c,d,ar1,n;

cout<<"\nEnter length of room:";

cin>>a;

cout<<"\nEnter width of room:";

cin>>b;

ar=calculate_area(a,b);

cout<<"\nArea of room:"<<ar<<" units";

cout<<"\nEnter length of mat:";

cin>>c;

cout<<"\nEnter width of mat:";

cin>>d;

ar1=calculate_area(c,d);

n=ar/ar1;

cout<<"\nNumber of mats required are:"<<n;

return 0;

}


Codehs 7.4.6:  gymnastics mats calculate how many mats will be needed to fill a room given the dimen
Computers and Technology
Step-by-step answer
P Answered by PhD

boolean rsvp;

int selection;

String option1;

String option2;

(a) if(rsvp){

System.out.println("Attending");

} else {

System.out.println("Not attending");

}

(b) if (selection == 1){

System.out.println("Beef");

} else if (selection == 2){

System.out.println("Chicken");

} else if (selection == 3) {

System.out.println("Pasta");

} else {

System.out.println("Fish");

}

(c) switch(selection){

case 1:

if(rsvp){

option1 = "Thanks for attending. You will be served beef.";

} else{

option1 = "Sorry you can't make it";

}

break;

case 2:

if(rsvp){

option1 = "Thanks for attending. You will be served chicken.";

} else{

option1 = "Sorry you can't make it";

}

break;

case 3:

if(rsvp){

option1 = "Thanks for attending. You will be served pasta.";

} else{

option1 = "Sorry you can't make it";

}

break;

default:

if(rsvp){

option1 = "Thanks for attending. You will be served fish.";

} else{

option1 = "Sorry you can't make it";

}

break;

}

(d) if (option1 == option2){

System.out.println("True");

} else {

System.out.println("False");

}

Explanation:

This code snippet is written in Java.

a) Uses if statement to print "attending" if rsvp is true and "not attending" if rsvp is false.

b) Uses if-else statement to print the variety of food based on user selection. If selection is 1, it print beef. If selection is 2, it print chicken. If selection is 3, it prints pasta else it print fish for any other value of selection.

c) Uses switch statement to determine the value of selection and then uses inner if statement to assign "Thanks for attending. You will be served beef." if rsvp is true to option1. The value of beef changes depending on the value of selection. If rsvp is false, then "Sorry you can't make it." is assigned to option1.

d) Uses if statement to print true if option1 and option2 are equal else it print false.

Computers and Technology
Step-by-step answer
P Answered by PhD

The technology that could be partnered with Cloud to allow the international fast-food chain to gain insights into customer data, including location and order patterns, is called data analytics or big data analytics. It involves using software algorithms and tools to analyze large and complex datasets like customer data, and extract useful insights and patterns that can be used to make informed decisions about customer-focused experiences such as promotions and unique user experiences. Data analytics can help businesses improve customer satisfaction, increase sales and revenue, and gain a competitive advantage in the marketplace.

Computers and Technology
Step-by-step answer
P Answered by Master
Answer options:
a. Cleaning a data visualization to remove unwanted patterns.
b. Iteratively creating visualizations to ask and answer new questions.
c. Cleaning data to remove inconsistencies.
d. Filtering the data to look at the responses from only certain groups.

Answer: is correct d. Filtering the data to look at the responses from only certain groups.

Try asking the Studen AI a question.

It will provide an instant answer!

FREE