In: Computer Science
Write a Python script that will collect 5 grades (float) from the student via input and obtain the average.
requirements:
a. Collect 5 floating grades from student
b. Obtain the average of the grades
# taking each input number on new line
print("enter five numbers") #to display message to input numbers
sum=0 # initializing sum to 0 to store sum of all numbers in future
for i in range(5): #for loop to take input of five float numbers
number=float(input()) #storing the input in variable 'number'
sum+=number #after taking input we add the number to sum (alternate line of code:sum=sum+number)
average=sum/5 #calculating average
print("average of five numbers is :",average) #printing average
###alternate code to take input of numbers on same line(space seperated):
# print("enter five numbers") #to display message to input numbers
# sum=0 # initializing sum to 0 to store sum of all numbers in future
# number=list(map(float,input().split()))[:5] #storing the input in list 'number'
# for i in range(5):
# sum+=number[i] #after taking input we add the number to sum (alternate line of code:sum=sum+number)
# average=sum/5 #calculating average
# print("average of five numbers is :",average) #printing average