Question

In: Computer Science

Programming Python Jupiter notebook Write a Python program that gets a numeric grade (on a scale...

Programming

Python Jupiter notebook

Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table.

The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range, it asks him/her to enter a numeric input in the correct range, instead of returning an error.


Example:
Enter your score: 78
Letter grade: C


Enter your score: seventy
Please enter a numeric score

Solutions

Expert Solution

Python code:

#accepting mark
mark=input("Enter your score: ")
try:
#trying to convert it into integer
mark=int(mark)
#checking if mark is in the range
if(mark<0 or mark>100):
#asking to enter it in range
print("Please enter a numeric score in range 0-100")
  
#checking if grade is A
if(mark>=90 and mark<=100):
#printing A grade
print("Letter grade: A")
#checking if grade is B
elif(mark>=80 and mark<=90):
#printing B grade
print("Letter grade: B")
#checking if grade is C
elif(mark>=70 and mark<=80):
#printing C grade
print("Letter grade: C")
#checking if grade is D
elif(mark>=60 and mark<=70):
#printing D grade
print("Letter grade: D")
elif(mark>=0 and mark<=60):
#printing E grade
print("Letter grade: E")
  
except:
#asking to enter numeric score
print("Please enter a numeric score")

Screenshot:


Input and Output:


Related Solutions

Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
Python Jupiter Notebook Write a program that keeps getting a set of numbers from user until...
Python Jupiter Notebook Write a program that keeps getting a set of numbers from user until the user enters "done". Then shows the count, total, and average of the entered numbers. Example: Enter a number: 55 Enter a number: 90 Enter a number: 12 Enter a number: done You entered 3 numbers, total is 157, average is 52.33333
In python of Jupiter notebook Write a python function called trng that takes three numbers x,...
In python of Jupiter notebook Write a python function called trng that takes three numbers x, y, and z, and specifies if those can form a triangle (i.e., returns the word triangle if they can, and Not a triangleotherwise). Note: In order for three numbers to form a triangle sum of any two of them must be greater than the third one (e.g., x=1, y=2, z=4 cannot form a triangle because x+y is not greater than z even though x+z>y...
Write a program in Python jupyter notebook for following: Part1: Course grade calculation: Course grades for...
Write a program in Python jupyter notebook for following: Part1: Course grade calculation: Course grades for CIS 1100 are calculated based on two assignments, a midterm exam, and a final exam. Here are the weights of these. Assignments 25% Midterm exam 35% Final exam 40% Ask the user for the scores they received for the two assignments, midterm exam, and the final exam. Then calculate and display their total weighted score they received for the course. Based on the weighted...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
1.1 Write a python in Jupiter notebook function called trng that takes three numbers x, y,...
1.1 Write a python in Jupiter notebook function called trng that takes three numbers x, y, and z, and specifies if those can form a triangle (i.e., returns the word triangle if they can, and Not a triangle otherwise). Note: In order for three numbers to form a triangle sum of any two of them must be greater than the third one (e.g., x=1, y=2, z=4 cannot form a triangle because x+y is not greater than z even though x+z>y...
Write a C# program using Repl.it that asks the user for a numeric grade between 0...
Write a C# program using Repl.it that asks the user for a numeric grade between 0 and 100, and displays a letter grade using the following conversion table: Numeric grade   Letter grade 90 < grade <= 100 A 80 < grade <= 90 B 70 < grade <= 80 C 60< grade <= 70 D grade <= 0.0 F Don’t forget the comments in your code. The output should be similar to: Enter the test score: 87 The letter grade...
Write a Python program that asks the user to enter a student's name and 8 numeric...
Write a Python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student determine_grade -...
PYTHON Write a program that asks the user to enter a student's name and 8 numeric...
PYTHON Write a program that asks the user to enter a student's name and 8 numeric assignment scores (out of 100 for each assignment). The program should output the student's name, a letter grade for each assignment score, and a cumulative average for all the assignments. Please note, there are 12 students in the class so your program will need to be able to either accept data for 12 students or loop 12 times in order to process all the...
Write a python program that asks the user to enter a student's name and 6 numeric...
Write a python program that asks the user to enter a student's name and 6 numeric tests scores (out of 100 for each test). The name will be a global variable. Create functions to calculate a letter grade for the student and calculate the average of the test scores for the student. The program should display a letter grade for each score, and the average test score, along with the student's name. Assume 6 students in the class. Functions in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT