Question

In: Computer Science

Write a Python script that will collect 5 grades (float) from the student via input and...

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

Solutions

Expert Solution

# 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


Related Solutions

MATLAB QUESTION Write a python program to request a positive float input from the user, x....
MATLAB QUESTION Write a python program to request a positive float input from the user, x. The program should check for the value of x. If x is larger than or equal to 1.0, the program should display the value of x in addition to the string “is larger than or equal to 1” and then terminate the program. If x is less than 1 the program should calculate y such that: y = 1-x+x^2/2-x^3/3+x^4/4-x^5/5……-x^99/99+x^100/100 The program should then display...
Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints...
Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints a message with information about the total amount owed and how much the tip was. As a reminder, the tip amounts are 10%, 15% and 20% for stingy, regular, and generous customers. And the tax amount should be 7%. The total amount is calculated as the sum of two amounts: check_amount = base_cost*1.07 tip_amount = tip_percentage*check_amount To receive full credit, you must use string...
Write a Python script that takes an input image and output's the name of the dominant...
Write a Python script that takes an input image and output's the name of the dominant color in that image(i.e. red, green, blue).  
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
Implement in Python a script that does the following: 1) reads input from a supposed file...
Implement in Python a script that does the following: 1) reads input from a supposed file called firstnames_2.txt. 2) processes the input and writes and saves the output to a file. NOTE: Please make sure that the names are written in the outfile with one name on each line no comma ( , ) after the name in the output
[JAVA SCRIPT] Please create an array of student names and another array of student grades. Create...
[JAVA SCRIPT] Please create an array of student names and another array of student grades. Create a function that can put a name and a grade to the arrays. Keep Read student name and grade until student name is “???”. And save the reading by using a function Create another function to show all the grade in that object. Create the third function that can display the maximum grade and the student’s name. Create a sorting function that can sort...
Python: write a program to first ask how many tests a student has taken, then collect...
Python: write a program to first ask how many tests a student has taken, then collect all the test scores and calculate the average score. After displaying the average score, the program also assigns a letter grade to the student according to the following grading scale: Score Grade >=90 A 80-89 B 70-79 C 60-69 D <60 F This program should perform input validation for test scores and only accept a positive input value as a score (ask the user...
Write a python program to read from a file the names and grades of a class...
Write a python program to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a gradesInput() function that reads data from a file and stores it and returns it as a dictionary....
In Python Write a function to read a Sudoku board from an input string. The input...
In Python Write a function to read a Sudoku board from an input string. The input string must be exactly 81 characters long (plus the terminating null that marks the end of the string) and contains digits and dots (the `.` character represents an unmarked position). The input contains all 9 rows packed together. For example, a Sudoku board that looks like this: ``` ..7 ... ... 6.4 ... ..3 ... .54 ..2 ... .4. ... 9.. ... ..5 385...
Design a Python script that accepts as input a user-provided list and transforms it into a...
Design a Python script that accepts as input a user-provided list and transforms it into a different list in preparation for data analysis, the transformed list replaces each numeric element in the original list with its base-10 order of magnitude and replaces string elements with blanks. Example: This script accepts as input a user-provided list expected to contain non-zero numbers and strings. It then prints a transformed list replacing numbers with their order of magnitude, and strings as blanks. Type...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT