Question

In: Computer Science

Next month there will a marathon. Ali, Mustafa, Ahmad, and Sami are friends and preparing for...

Next month there will a marathon. Ali, Mustafa, Ahmad, and Sami are friends and preparing for it. Each day of the week, they run a certain number of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day.

Write a program to help them analyze their data. Your program must contain:

  • parallel arrays: an array to store the names of the runners and
  • a two-dimensional array of 4 rows and seven columns to store the number of miles run by each runner each day.
  • then implement the following functions:
    • a function to read and store the runners’ names and the numbers of miles run each day;
    • a function to find the total miles run by each runner and the average number of miles run each day

a function to output the results

Solutions

Expert Solution

Since the language is not provided I am doing the question in python:

Code:

read_score()- to read and store player names and miles/day.

manipulations(scores, player) : to find total miles by each of the 4 players and average of their score.

output(): to print player name and their score, the average and sum of scores.

import numpy as np
def read_store():
players=[]
score=[]
name=input("Enter name of player 1 is ")
players.append(name)
name=input("Enter name of player 2 is ")
players.append(name)
name=input("Enter name of player 3 is ")
players.append(name)
name=input("Enter name of player 4 is ")
players.append(name)
for i in range(len(players)):
score1=[]
print("Enter the score for player ", i+1)
sc=float(input("Enter score of day 1 is "))
score1.append(sc)
sc=float(input("Enter score of day 2 is "))
score1.append(sc)
sc=float(input("Enter score of day 3 is "))
score1.append(sc)
sc=float(input("Enter score of day 4 is "))
score1.append(sc)
sc=float(input("Enter score of day 5 is "))
score1.append(sc)
sc=float(input("Enter score of day 6 is "))
score1.append(sc)
sc=float(input("Enter score of day 7 is "))
score1.append(sc)
score.append(score1)
score=np.asarray(score)
players=np.asarray(players)
return players, score

def manipulations(scores,player):
for i in range(len(scores)):
print("Sum of score of", player[i], "is", np.sum(scores[i]))
print("Average of score of", player[i], "is", np.sum(scores[i])/7)

def output():
players, scores= read_store()
for i in range(len(players)):
print(players[i],scores[i])
manipulations(scores,players)
output()

To avoid indentation errors I am attaching images:

First run read_score() and then manipulations(scores, player) and then output().

Output:

Enter name of player 1 is ALI
Enter name of player 2 is MUSTUFA
Enter name of player 3 is AHMAD
Enter name of player 4 is SAMI
Enter the score for player 1
Enter score of day 1 is 1
Enter score of day 2 is 2
Enter score of day 3 is 3
Enter score of day 4 is 4
Enter score of day 5 is 5
Enter score of day 6 is 6
Enter score of day 7 is 7
Enter the score for player 2
Enter score of day 1 is 2
Enter score of day 2 is 3
Enter score of day 3 is 4
Enter score of day 4 is 5
Enter score of day 5 is 6
Enter score of day 6 is 7
Enter score of day 7 is 8
Enter the score for player 3
Enter score of day 1 is 3
Enter score of day 2 is 4
Enter score of day 3 is 5
Enter score of day 4 is 6
Enter score of day 5 is 6
Enter score of day 6 is 7
Enter score of day 7 is 8
Enter the score for player 4
Enter score of day 1 is 9
Enter score of day 2 is 8
Enter score of day 3 is 7
Enter score of day 4 is 6
Enter score of day 5 is 4
Enter score of day 6 is 3
Enter score of day 7 is 1
ALI [1. 2. 3. 4. 5. 6. 7.]
MUSTUFA [2. 3. 4. 5. 6. 7. 8.]
AHMAD [3. 4. 5. 6. 6. 7. 8.]
SAMI [9. 8. 7. 6. 4. 3. 1.]
Sum of score of ALI is 28.0
Average of score of ALI is 4.0
Sum of score of MUSTUFA is 35.0
Average of score of MUSTUFA is 5.0
Sum of score of AHMAD is 39.0
Average of score of AHMAD is 5.571428571428571
Sum of score of SAMI is 38.0
Average of score of SAMI is 5.428571428571429

I am also attaching the image of final o/p:


Related Solutions

One of your friends is preparing for a run in a marathon. She has heard about...
One of your friends is preparing for a run in a marathon. She has heard about eating a pasta dinner to glycogen load the evening prior to the marathon. Explain in biochemical terms what glycogen loading is and how it works? Please include hormonal controls, key enzymes and a discussion of both liver and muscle in the process.
The partnership agreement of Ahmad, Fatima, and Ali provides for annual distribution of profit and loss...
The partnership agreement of Ahmad, Fatima, and Ali provides for annual distribution of profit and loss in the following sequence: • Fatima, the managing partner, receives a bonus of 10% of net income. • Each partner receives 5% interest on average capital investment. • Residual profit or loss is to be divided 4:2:4. • Average capital investments for 2019 were: Ahmad $270,000 Fatima $180,000 Ali $120,000 At the end of 2019, the partnership reported net loss before interest, salaries, and...
Ali and Ahmad are two managers at ABC corporation working in a shop with processes V,...
Ali and Ahmad are two managers at ABC corporation working in a shop with processes V, W, X, Y, Z. These processes are somewhat similar and can be arranged in any manner. Ahmad thinks the best arrangement is V, W, X, Y, Z while Ali thinks it is best to reverse the arrangement and make it Z, Y, X, W, V. If you know that each process has a scrap rate as follows: V: 5% W: 4% X: 2% Y:...
Question 4. (Answer must be collectively 200 to 250 words) 1. As Mr. Marwan Ali Ahmad...
Question 4. (Answer must be collectively 200 to 250 words) 1. As Mr. Marwan Ali Ahmad Al Amri- Sales Manager of the Mac Computer Hardware store Al-Qurm Muscat, write a reply letter to the purchase manager of Saud Bahwan IT division, who has recently written a complaint letter to you (above question 3) complaining about the improper functioning of some keyboards and computer Mouse models that he had purchased from your store. Try to pacify the angry customer and give...
Summary Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of...
Summary Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day and average miles run each day. Instructions Write a program to help them analyze their data. Your program must contain parallel arrays: an array to store the names of the runners...
Question 2: Assume, Mr. Ali, one of your friends completed his graduation in Engineering and wanted...
Question 2: Assume, Mr. Ali, one of your friends completed his graduation in Engineering and wanted to start a small manufacturing company near Salalah, and he intends to get some idea on the cost enunciated hereunder: i) Classification of cost on the basis of Controllability, and ii) Classification of cost on the basis of Variability. Being the accounting specialization student how will you explain him about classification of cost? Explain along with suitable examples. (, Word Limit 250-350
Ali wants to accumulate at least $40,000 by depositing $1,600 at the end of each month...
Ali wants to accumulate at least $40,000 by depositing $1,600 at the end of each month into a fund that earns interest at 5.75% compounded monthly. a. How many deposits does he need to make in order to reach his goal? b. How long will it take Ali to reach his goal? year(s) month(s)
You can pay $91 per month, starting next month, for the next 5 years to have...
You can pay $91 per month, starting next month, for the next 5 years to have a lawn mowing service. Alternatively, you can purchase a riding lawn mower and pay $506 today and mow your own lawn for 5 years, starting next month. If you decide to mow your own lawn, how much do you save in PV terms if your investments earn 3.31% APR, compounded monthly? Note: If you would lose money, make your answer with a negative sign...
Case Study: Shannon Shannon is a 30-year-old woman preparing to run her first marathon. She regularly...
Case Study: Shannon Shannon is a 30-year-old woman preparing to run her first marathon. She regularly runs 30km per week, attends the gym three times per week doing a mix of cardio- and weight training sessions and also plays touch football once a week in a social work team. She is up early most mornings and when she does not run will either practice yoga at home or do a 30- to 40-minute power walk. Shannon ran competitively throughout secondary...
Assume that Ali Services company bills its clients for jobs completed during the month. On October...
Assume that Ali Services company bills its clients for jobs completed during the month. On October 31, 2004, Ali Services company billed its clients $450,000 for products sold during October. During November, Ali Services company collected 20 percent of its sales billed on October 31. the cost price this products was $200,000 which is paid 80 percent in cash. What would be recorded by Ali Services company under the cash basis?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT