Question

Write a Python program that asks the user to type in their three quiz scores (scores...

Write a Python program that asks the user to type in their three quiz scores (scores between 0 and 100) and displays two averages. The program should be written so one function gets the user to input a score, another function takes the three scores and returns the average of them. And another function takes the three scores and averages the two highest scores (in other words, drops the lowest). Each of these functions should do the computation and return the result so it can be used by the main function. Here is the algorithm of the main function:

main()

call function to get the first score hint: score1 = getScore() where getScore is a function that runs a while loop to get user input until the input is between 0 and 100

call the function again to get the second score hint: score2 = getScore()

call the function a third time to get the third score.

By now, you have three scores from the user and they are all in the valid score range.

call your function to average the three scores. Assign it's return value to average. Hint: average = getAverage(score1,score2,score3)

call your function to get the average with the lowest score dropped.  

print out both averages.

Be sure to document each function - description, arguments, and return value

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please upvote ,comment for any query . Thanks.

Note : check attached image for output and program indentation .Program compiled and tested in Spyder Python3.

Program :

'''
Program object to get three score from user between 0 to 100 and print
the average of all three scores and average of highest two scores
  
'''


'''
getScore()

paramter- function don't take any paramtere
getScore() prompt user to enter a score between 0 to 100
and return that score . function will ask untill user not enter valid score
return score
  
'''

def getScore():
score =-1
while(score<0 or score >100):
score =int(input("Enter score(0 to 100):"))
return score

'''
getAverage(score1,score2,score3)
paramter- function take three valid score
  
getAverage takes three score and calculate average of three
  
return average of all three passed score
  
'''


def getAverage(score1,score2,score3):
average=(score1+score2+score3)/3
return round(average,2)


'''
getAveraeOfTwo(score1,score2,score3)
paramter : takes three valid score as paramter
checks for lowest score and add both highest score and calculate average
return the average of highest score

'''
def getAverageOfTwo(score1,score2,score3):
if score1<=score2 and score1<=score3:
average=(score2+score3)/2
return round(average,2)
elif score2<=score1 and score2<=score3:
average=(score1+score3)/2
return round(average,2)
elif score3<=score1 and score3<=score2:
average=(score1+score2)/2
return round(average,2)
else:
average=(score2+score3)/2
return round(average,2)

if __name__ == "__main__":
score1=getScore() #score1 from user
score2=getScore() #score2 from user
score3=getScore() #score3 from user
#return all average of all three scores
average1=getAverage(score1,score2,score3)
#return the average of two highest score
average2=getAverageOfTwo(score1, score2, score3)
#print both average score
print("Average of all three scores: ",average1)
print("Average of two highest scores : ",average2)
  
  
  
Output :

Program 1 :

Program 2:

Please upvote ,comment for any query .

Add a comment
Know the answer?
Add Answer to:
Write a Python program that asks the user to type in their three quiz scores (scores...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that will ask the user to enter 4 quiz scores. These scores should...

    Write a program that will ask the user to enter 4 quiz scores. These scores should be from 0 to 100. Use a procedure and pass by reference to get these scores. Write a function that will find the lowest score. This score will be sent back through the function call. You still need to pass the scores by value to this function. Write a function that will calculate the average score. This value will be sent back to main...

  • 1 // This program averages 3 test scores. 2 // It uses the variable perfectScore as...

    1 // This program averages 3 test scores. 2 // It uses the variable perfectScore as a flag. 3 include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 cout << "Enter your 3 test scores and I will "; 9 << "average them:"; 10 int score1, score2, score3, 11 cin >> score1 >> score2 >> score3; 12 double average; 13 average = (score1 + score2 + score3) / 3.0; 14 if (average = 100); 15 perfectScore...

  • Find errors in code and get 100% feedback!! Foblem (30 Points) This program This programaverages >...

    Find errors in code and get 100% feedback!! Foblem (30 Points) This program This programaverages > // It uses the ram has errors. Find the errors in the code: n averages 3 test scores. the variable perfect Score as a flag. Line # Line # include <iostream> using namespace std; int maino cout << "Enter your 3 test scores and I will ": <<"average them;": int score1, score2, score3, cin >> score1 >> score2 >> score3; double average; average (scorel...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • You are to write a program IN C++ that asks the user to enter an item's...

    You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...

  • Question: - write a C++ program that asks user to enter students' quiz scores, calculate the...

    Question: - write a C++ program that asks user to enter students' quiz scores, calculate the total score for each students and average for all. Note: - number of students: 1 through 5. That is, at least one student and up to 5. - number of quizes: 8 through 10. That is, at least 8 quizes and up to 10. - quiz score range: 0 through 100. - when entering quiz scores, if user enters -1, that means the user...

  • I need help with this c++ question please thank you ltls. The program should urt valte....

    I need help with this c++ question please thank you ltls. The program should urt valte. 11. Lowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getscore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • Use your knowledge of algorithm development to create a program using RAPTOR to solve the problem...

    Use your knowledge of algorithm development to create a program using RAPTOR to solve the problem below. Input a list of student names (in to array student[]) and testing scores stored in parallel arrays. Each student have 3 testing scores ranging from 0 to 100 (store into parallel array score1[], score2[], score3[]). Output average score for each student and print out what is his final grade. If average score <60, got F grade. If 60<=average score<70, got D grade. If...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT