subject
Computers and Technology, 10.05.2021 18:30 bre563

In this lab, you complete a partially prewritten Python program that uses a list. The program prompts the user to interactively enter eight batting averages, which the program stores in an array. It should then find the minimum and maximum batting averages stored in the array, as well as the average of the eight batting averages. The data file provided for this lab includes the input statement and some variable declarations. Comments are included in the file to help you write the remainder of the program.
Instructions
Make sure the file BattingAverage. py is selected and open.
Write the Python statements as indicated by the comments.
Execute the program by clicking the "Run Code" button at the bottom of the screen. Enter the following batting averages: .299, .157, .242, .203, .198, .333, .270, .190. The minimum batting average should be .157 and the maximum batting average should be .333. The average should be .2365.
Grading
When you have completed your program, click the "Grade" button to record your score.
Lists
BattingAverage. py
4
43
Unix Terminal>
1 # Declare a named constant for array size here.
2 MAX_AVERAGES = 8
3?
4 # Declare array here.
5 averages = []
6 ?
7 # Write a loop to get batting averages from user and assign to array.
8 for i in range(MAX_AVERAGES):
9 averageString = input("Enter a batting average: ")
10 battingAverage = float(averageString)
11 # Assign value to array.
12 averages. append(battingAverage)
13 ?
14 # Assign the first element in the array to be the minimum and the maximum.
15 minAverage = averages[0]
16 maxAverage = averages[0]
17 # Start out your total with the value of the first element in the array.
18 total = averages[0]
19 # Write a loop here to access array values starting with averages[1]
20 ?
21 # Within the loop test for minimum and maximum batting averages.
22 for i in range(1, MAX_AVERAGES):
23 f averages[i] < minAverage:
24 minAverage = averages[i]
25 if averages[i] > maxAverage:
26 maxAverage = averages[i]
27 total += averages[i]
28 ?
29 # Also accumulate a total of all batting averages.
30 ?
31 ?
32 # Calculate the average of the 8 batting averages.
33 average = total / MAX_AVERAGES
34 ?
35 # Print the batting averages stored in the averages array.
36 for avg in averages:
37 print(avg)
38 ?
39 # Print the maximum batting average, minimum batting average, and average batting average.
40 print('Maximum batting average is ' + str(maxAverage))
41 print('Minimum batting average is ' + str(minAverage))
42 print('Average batting average is ' + str(average))
43 ?
W
Run Code
Ctrl + Enter
TestGrade

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:30, enazer
Type the correct answer in the box. spell all words correctly. what kind of graph or chart does this image represent? the given image represents a (blank).
Answers: 2
image
Computers and Technology, 22.06.2019 05:00, 105001964
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. after the loop terminates, it prints out, on a line by itself and separated by spaces, the sum of all the even integers read, the sum of all the odd integers read, a count of the number of even integers read, and a count of the number of odd integers read, all separated by at least one space. declare any variables that are needed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system. in); is given.
Answers: 3
image
Computers and Technology, 24.06.2019 22:30, toricepeda82
What are the 4 basic items that are traded throughout the world?
Answers: 1
image
Computers and Technology, 25.06.2019 08:00, Jroc23
What are good colleges to apply to if you got like a 2.5 as a gpa? already got a call back from gcu at least its a start rt
Answers: 2
You know the right answer?
In this lab, you complete a partially prewritten Python program that uses a list. The program prom...

Questions in other subjects: