this code is not working for me.. if enter 100 it is not showing the grades insted asking for score again..
#Python program that prompts user to enter the valuesof grddes . Then calculate the total scores , #then find average of total score. Then find the letter grade of the average score. Display the #results on python console.
#grades.py
def main():
#declare a list to store grade values
grades=[]
repeat=True
#Set variables to zero
total=0
counter=0
average=0
gradeLetter=''
#Repeat loop till user enters -1 to stop
while repeat:
#try-catch block to check if input is number
try:
value = int(input('Enter score : '))
#Check if value is -1
if value==-1:
#set repeat to False to stop execution
repeat=False
else:
#increment the counter by 1
counter=counter+1
#add value to total
total=total+value
#add value to grades
grades.append(value)
except ValueError:
print('Invalid input')
#calculate the average score
average=total/counter
#find the letter grade for average value
if average>=92.50 and average<=100:
gradeLetter='A'
elif average>=88.5 and average<=92.49:
gradeLetter='B+'
elif average>=82.50 and average<=88.49:
gradeLetter='B'
else:
gradeLetter = 'F'
#Print total score
print('Total Score',total)
# Print average
print('Average',average)
# Print gradeLetter
print('Letter Grade',gradeLetter)
#calling main method
main()Here is the answer..
If you need score for each grade then below is the code
CODE:
def main():
#declare a list to store grade values
grades=[]
repeat=True
#Set variables to zero
total=0
counter=0
average=0
gradeLetter=''
#Repeat loop till user enters -1 to stop
while repeat:
#try-catch block to check if input is number
try:
value = int(input('\nEnter score : '))
#Check if value is -1
if value==-1:
#set repeat to False to stop execution
repeat=False
else:
#increment the counter by 1
counter=counter+1
#add value to total
total=total+value
#add value to grades
grades.append(value)
#calculate the average score
average=total/counter
#find the letter grade for average value
if average>=92.50 and average<=100:
gradeLetter='A'
elif average>=88.5 and average<=92.49:
gradeLetter='B+'
elif average>=82.50 and average<=88.49:
gradeLetter='B'
else: gradeLetter = 'F'
#Print total score
print('Total Score',total)
# Print average
print('Average',average)
# Print gradeLetter
print('Letter Grade',gradeLetter)
except ValueError:
print('Invalid input')
main()
OUTPUT:

If you want result at end of the grades then your code is working fine....Here is the outputs
OUTPUT:\


If you have any doubts please COMMENT...
If you understand the answer please give THUMBS UP..
this code is not working for me.. if enter 100 it is not showing the grades...
Please provide pseudocode for the following python program: class Student: def t(self,m1, m2, m3): tot= m1+m2+m3; average = tot/3; return average class Grade(Student): def gr(self,av): if av>90: print('A grade') elif (av<90) and (av>70): print('B grade') elif (av<70) and (av>50): print('C grade') else: print('No grade') print ("Grade System!\n") s=Student(); repeat='y' while repeat=='y': a=int(input('Enter 1st subject Grade:')) b=int(input('Enter 2nd subject Grade:')) c=int(input('Enter 3rd subject Grade:')) aver=s.t(a,b,c); g=Grade(); g.gr(aver); repeat=input("Do you want to repeat y/n=")
Write a Python Program Display the grades: Input: Enter the marks of the student Condition: Grade A: Marks greater than 90 Grade B: Marks range from 81 to 90 Grade C: Marks range from 65 to 80 Fail: less than 65 Display the output. Example: Input: 95 Display: “student got Grade A” Input: 80 Display: “student got Grade C” Input: 64 Display: “student failed” Hint: Use else if (elif and logical operators)
25.6 Ch. 03: Assign Midterm Grades (input, if, print) Assume the maximum midterm exam score is 60. Write a program to ask the user to enter a student's score and print out a letter grade according to following table. Grade Weighted Score 904 or higher 808 or higher 700 or higher 600 or higher Lower than 605 A sample input/output interaction will look like the follows. Please enter a midterm score: 50 Grade for 50.0 will be B ACTIVITY 25.6.1:...
A. Write a Python script so that the user can enter any number of grades. Create a calcavg() function so that it takes the number of grades as a parameter and returns the regular average (not a weighted average). You must loop through the grades for full credit. Add a try/except block so that if a non-numeric value is entered, you get the error message shown below. You cannot use lists. Input: c. python …\IT2430\FirstLastname\assign5-2.py 96.7 95.6 87.0 d. python...
I've built a C++ program that calculates the user's class average based on three test. Can somebody show me how to get the program to look for invalid input? #include <iostream> #include <string> #include <iomanip> using namespace std; int main() { //variables int score_1; //test 1 input from user int score_2; //test 2 input from user int score_3; //test 3 input from user int highest; // the higher score of test 1 & 2 int course_average; //average for class //Introduce...
Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...
Please make this Python code execute properly. User needs to create a password with at least one digit, one uppercase, one lowercase, one symbol (see code), and the password has to be atleast 8 characters long. try1me is the example I used, but I couldn't get the program to execute properly. PLEASE INDENT PROPERLY. def policy(password): digit = 0 upper = 0 lower = 0 symbol = 0 length = 0 for i in range(0, len(password)): if password[i].isdigit(): # checks...
Professor Dolittle has asked some computer science students to write a program that will help him calculate his final grades. Professor Dolittle gives two midterms and a final exam. Each of these is worth 100 points. In addition, he gives a number of homework assignments during the semester. Each homework assignment is worth 100 points. At the end of the semester, Professor Dolittle wants to calculate the median score on the homework assignments for the semester. He believes that the...
Java I am stuck on, enter a number grade: 9.8 ERROR: 9.8 and enter a number grade: 10 ERROR: 10 Here is the specs Write a class called Grades. Grades must have a main method (see example of what the main method does below). Grades are values between zero and 10 (both zero and 10 included), and are always rounded to the nearest half point (i.e. ALL GRADES entered in the system end in either .0 or .5). To...