-
Home
-
Program to Calculate Score Average in Python Assignment Solution.
Instructions
Objective
Write a program to calculate score average in python.
Requirements and Specifications
Write a program that calculates the average of the scores in a list. The program should print the list before calculating the average and after it is calculated.
Hints:
Create a list with numbers
Print the list
Calculate the total of the list elements using a for loop
Calculate the average of the elements (use len function) and display the avg
Write a program that demonstrates the insert method. The program should print the list before and after the insert.
Hints:
Create a list with 6 names
Print the list
Call the insert function to insert another name in ‘5’ element of the list and then print the list.
Write a program that asks the User to enter a series of 5 numbers. The program should store the numbers in the list and then display the Lowest and Highest number in the list.
Hints:
Create an empty list
Define variables
Prompt the user for numbers and use a for loop store the numbers in the list (use append method).
Use min and max function to calculate Low and high numbers
OUTPUT should look like :
Source Code
Q1
# Create a list with numbers
scores = [72, 41, 58, 60, 97, 65, 59, 57, 10, 56]
# Print the list
print("Scores = " + str(scores))
# Calculate the total
total = 0
for score in scores:
total += score
# Calculate the average
average = total / len(scores)
# Display average
print("Average = " + str(average))
Q2
# Create a list with 6 names
names = ['Alice', 'Bob', 'Charlie', 'Dan', 'Esther', 'Fred']
# Print the list
print("Names = " + str(names))
# Insert another an element on the 5th elements
names.insert(4, 'Susan')
# Print the list
print("Names = " + str(names))
Q3
# Create an empty list
numbers = []
# Input 5 numbers
for i in range(5):
numbers.append(float(input("Enter number " + str(i + 1) + " of 5: ")))
# Get the min and max values in the numbers
print("Low: " + str(min(numbers)))
print("High: " + str(max(numbers)))