Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Im stuck in the middle of this program. I got the beginning and end working. It prints the averages all in one line with single
Im stuck in the middle of this program. I got the beginning and end working. It prints the averages all in one line with single space between and it prints the min, max and average. But I can't get it to print the averages position in the array Below is what I need the results to show. Below that, is my current code. Thank you.
Enter a batting average:
Enter a batting average:
Enter a batting average:
Enter a batting average:
Enter a batting average:
Enter a batting average:
Enter a batting average:
Enter a batting average:
averages is:
averages is:
averages is:
averages is:
averages is:
averages is:
averages is:
averages is:
Minimum batting average is
Maximum batting average is
Average batting average is
# Initialize an integer for list size here.
numAverages
# Initialize list here.
averages
# Write a loop to get batting averages from user and add to list.
for i in range:
# String version of batting average input by user.
averageString inputEnter a batting average:
# Use this variable to store the batting average input by user.
battingAverage floataverageString
# add value to list.
averages.appendbattingAverage
# Use these variables to store the minimim and maximum batting averages.
minAverage minaverages
maxAverage maxaverages
totalaverage sumaverages
# Assign the first element in the list to be the minimum and the maximum.
min averages
max averages
# Start out your total initialized to
total
# Write a loop here to access list values starting with averages
for i in rangelenaverages:
# Within the loop test for minimum and maximum batting averages.
if averagesi minAverage:
minAverage averagesi
if averagesi maxAverage:
maxAverage averagesi
# Also accumulate a total of all batting averages.
total averagesi
# Calculate the average of the averages.
average total
# Print the averages stored in the averages list.
printaveragesiis:
for i in averages:
printi
# Print the maximum batting average, minimum batting average, and average batting average.
print
Minimum batting average:", minAverage
printMaximum batting average:", maxAverage
printAverage batting average:", average
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started