Question

Write a program that requests some grades as inputs, and displays the average after dropping the...

Write a program that requests some grades as inputs, and displays the average after dropping the smallest and the largest grades! Your program should stop asking the user for a new grade when the user typed any negative number.

Here is a sample run:

Enter a grade?40

Enter a grade?50

Enter a grade?60

Enter a grade?70

Enter a grade?80

Enter a grade?90

Enter a grade?100

Enter a grade?-1

70.0

Note that in this example 40 is the lowest grade and 100 is the largest grade, and therefore are dropped, then the average is (50+60+70+80+90)/5=70.

Do this in python

Homework Answers

Answer #1

The code is given below-

lst=[]
count=0
n=int(input("Enter a grade?"))
if(n>=0):
    while(n>=0):
        lst.append(n)    #entering the values in the list
        count=count+1     #counting the number of elements
        n=int(input("Enter a grade?"))
    max_value=max(lst)   #finding max value from list
    min_value=min(lst)    #finding min values
    #print(max_value)
    count=count-2     #removing count for max and min value
    sum_value=0
    lst.remove(max_value)   #removing max value
    lst.remove(min_value)   #removing min value
    if(count>0):
        for i in lst:
               # print(i)
                sum_value=sum_value+i   #summing up the values 
        avg=sum_value/count    #calculating average
        print(avg)
    else:
        print('0')
        
        

the screenshot is attached below-

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program in C to find the student’s eligibility for admission into some academic program....
Write a program in C to find the student’s eligibility for admission into some academic program. Ask the user to enter three grades for Maths, Physics, and Chemistry. Then if: The student’s grade in Math is greater than 80 and in Physics is greater than 70, the student is eligible to study Engineering. The student’s grade in Physics is greater than 80 or Chemistry is greater than 90, the student is eligible to study Sciences. Otherwise, the student is not...
You are to write a program that will process students and their grades. For each student...
You are to write a program that will process students and their grades. For each student the program will read in a student’s name. It should also read in 10 test scores for the student and calculate his or her average. You must read the scores using a loop. The program should output the student’s name, average and letter grade. The average should be displayed accurate to 1 decimal digit. Letter grades are assigned based on the scale: 90-100    A...
C++ Write a program which accepts a numeric test score from the user. It will output...
C++ Write a program which accepts a numeric test score from the user. It will output the letter grade to the user corresponding to the score. Assume no “minus grades” (an A ranges from 90-100, B ranges from 80-89, C ranges from 70-79, D ranges from 60-69 and F is everything else.) Ensure that the score remains in the range of 0 to 100. As an example of the output: Enter your numeric grade and I will tell you your...
Write a program that keeps reading a test score until a -1 is entered. The program...
Write a program that keeps reading a test score until a -1 is entered. The program will output the letter grade according to the table below: Score Grade 90-100.   A 80-89.   B 70-79.   C 60-69.   D < 60.   F For example: Enter a Score (-1 to Exit): 92 The Letter grade for that score is A. Enter a Score (-1 to Exit): -1
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
Write a Java program to display a letter grade based on an actual grade. A =...
Write a Java program to display a letter grade based on an actual grade. A = 90-100 B = 80-89 C = 70-79 D = 60-69 F = less than 60 The program needs to do the following: 1. Create a short integer to store a grade. (See Week 3 - Things to Know - Java Data Types ) 2. Prompt for a grade ( 0-100). 3. Based on the grade given, use IF statements to display the letter grade...
5) Create a Java program using Scanner: Write a program where you will enter the grade...
5) Create a Java program using Scanner: Write a program where you will enter the grade score for 5 classes, then it will display total points and average and it will display the grade based on percentage. Steps: 1) Declare variable integer for English, Chemistry, Java Programming, Physics and Math 2) Declare variable total and percentage 3) Create Scanner object and prompt the user to enter grades for each class and input grades after each class 4) Calculate total of...
Create a program to calculate and print basic stats on a set of a given input...
Create a program to calculate and print basic stats on a set of a given input values representing students' scores on an quiz. 1) Ask the user for the total number of quiz scores to be input (assume a positive integer will be given). 2) Create an array to hold all the quiz scores and then get all the scores from input to put into the array. For example, if the user input 10 in step (1) then you should...
Write a java program that creates an integer array with 50 random values, prompts the user...
Write a java program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. “Out of Bounds”) and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle invalid inputs,...
1: Compute measures of central tendency below: a)Mean, median, and mode for the grades taken by...
1: Compute measures of central tendency below: a)Mean, median, and mode for the grades taken by students b)Mean, median, and mode for the number of hours studied Discussion question 2: Does the number of hours studied correlate with the grades taken? Please provide a narrative explaining the relationship between the number of hours studied and the grades by running correlation analysis in Excel. In Excel, use insert function to compute the measures of central tendency and use the CORREL function...