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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
What does a cascading style sheet resolve a conflict over rules for an element? a. the rule affecting the most content wins b. the rule affecting the most content loses c. the rule with the most specific selector loses d. the rule with the most specific selector wins
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Drag the tiles to the correct boxes to complete the pairs. match the errors with their definitions. #name #value #ref when a formula produces output that is too lengthy to fit in the spreadsheet cell arrowright when you enter an invalid cell reference in a formula arrowright when you type text in cells that accept numeric data arrowright when you type in a cell reference that doesn’t exist arrowright reset next
Answers: 1
question
Computers and Technology, 24.06.2019 18:50
Write a program that reads in a series of lines of input character by character (using the library function the first line of the input contains an integer which specifies the number of remaining lines of input, each of which contains a floating point number. the integer value on the first line can be read with (the library function) but all of the following lines can only be read with each line, after the first, contains a single floating point value, with up to four digits before the decimal point, and up to four digits following the decimal point, but there is not necessarily a decimal point in each number; i.e., it may appear to be an integer, but the digits should be read by your program, and the number should be converted to a corresponding floating point number. for instance, suppose the following input: 5 3.1255 20.25 0.875 1921.50 31 the required output is: − each of the input floating point values, printed on a separate line with four digits of precision, using printf(); − on the last line of the output, the string “total: ” followed by the sum of the input values, printed with printf() to 4 digits of precision. for example, the total of the sample input given above is 1976.7505, so the required output for this input would be: 3.1255 20.2500 0.8750 1921.5000 31.0000 total: 1976.7505 do not concern yourself with small differences in the total due to rounding, as the grader will not deduct points for this. constraints: − you are not allowed to use arrays on this portion of the lab assignment. − there is no maximum number of lines allowable. it all depends upon the first value of input. since you aren’t saving anything, it doesn’t matter. − you can assume that input will not contain more than 4 digits before or after the decimal point. you do not need to error check for this condition. -you must use getchar() to read in the floating point values one character at a time (i.e. do not use -you must declare and use your floating point values as a double to minimize rounding errors. -only use printf() to output the floating point numbers and the total (do not use − be sure your directions to the user are clear so they are sure to enter the input data correctly.
Answers: 1
question
Computers and Technology, 25.06.2019 04:40
1. instructions: in your response, make an argument for whether for whether it is better for waketown to build its new wake heights subdivision or to preserve the wake wetlan to preserve the wake wetland preserve. use evidence from at least two of the sources below to support your claim. be sure to introduce your precise claim, develop the claim with evidence from the sources, and demonstrate relationships between ideas. (15 points)
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
question
Social Studies, 20.08.2019 14:30
question
Mathematics, 20.08.2019 14:30
question
Mathematics, 20.08.2019 14:30
question
Mathematics, 20.08.2019 14:30
question
Mathematics, 20.08.2019 14:30