Show the code for a python program that 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 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.   # Declare a named constant for array size here. MAX_AVERAGES = 8 # Declare array here. # Write a loop to get batting averages from user and assign to array.     averageString = input("Enter a batting average: ")     battingAverage = float(averageString)     # Assign value to array. # Assign the first element in the array to be the minimum and the maximum. minAverage = averages[0] maxAverage = averages[0] # Start out your total with the value of the first element in the array. total = averages[0] # Write a loop here to access array values starting with averages[1]     # Within the loop test for minimum and maximum batting averages.     # Also accumulate a total of all batting averages. # Calculate the average of the 8 batting averages. # Print the batting averages stored in the averages array. # Print the maximum batting average, minimum batting

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

Show the code for a python program that 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

  1. Make sure the file BattingAverage.py is selected and open.
  2. Write the Python statements as indicated by the comments.
  3. Execute the program by clicking the Run 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.

 

# Declare a named constant for array size here.
MAX_AVERAGES = 8

# Declare array here.

# Write a loop to get batting averages from user and assign to array.

    averageString = input("Enter a batting average: ")
    battingAverage = float(averageString)
    # Assign value to array.

# Assign the first element in the array to be the minimum and the maximum.
minAverage = averages[0]
maxAverage = averages[0]
# Start out your total with the value of the first element in the array.
total = averages[0]
# Write a loop here to access array values starting with averages[1]

    # Within the loop test for minimum and maximum batting averages.




    # Also accumulate a total of all batting averages.


# Calculate the average of the 8 batting averages.


# Print the batting averages stored in the averages array.


# Print the maximum batting average, minimum batting average, and average batting average.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Python is showing the code as incomplete when running test program.

Output
Enter a batting average: .299
Enter a batting average: .157
Enter a batting average: .242
Enter a batting average: .203
Enter a batting average: .198
Enter a batting average: .333
Enter a batting average: .27O
Enter a batting average: .190
The batting averages stored in the array are:
0.299
0.157
0.242
0.203
0.198
0.333
0.27
0.19
The maximum batting average is: 0.333
The minimum batting average is: 0.157
The average of the batting averages is: 0.2365
Results O
Minimum batting average is 0.157 Maximum batting average is 0.333
Average batting average is 0.236
Expected Output ®
Minimum batting average is 0.157 Maximum batting average is 0.333
Average batting average is 0.236
Transcribed Image Text:Output Enter a batting average: .299 Enter a batting average: .157 Enter a batting average: .242 Enter a batting average: .203 Enter a batting average: .198 Enter a batting average: .333 Enter a batting average: .27O Enter a batting average: .190 The batting averages stored in the array are: 0.299 0.157 0.242 0.203 0.198 0.333 0.27 0.19 The maximum batting average is: 0.333 The minimum batting average is: 0.157 The average of the batting averages is: 0.2365 Results O Minimum batting average is 0.157 Maximum batting average is 0.333 Average batting average is 0.236 Expected Output ® Minimum batting average is 0.157 Maximum batting average is 0.333 Average batting average is 0.236
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT