Question

In: Computer Science

Write a python program. Grades are values between zero and 10 (both zero and 10 included),...

Write a python program. Grades are values between zero and 10 (both zero and 10 included), and are always rounded to the nearest half point. To translate grades to the American style, 8.5 to 10 become an “A,” 7.5 and 8 become a “B,” 6.5 and 7 become a “C,” 5.5 and 6 become a “D,” and other grades become an “F.” Implement this translation, whereby you ask the user for a grade, and then give the American translation. If the user enters a grade lower than zero or higher than 10, just give an error message. You do not need to handle the user entering grades that do not end in .0 or .5, though you may do that if you like – in that case, if the user enters such an illegal grade, give an appropriate error message.

Solutions

Expert Solution

#takes grade from user
grade = float(input("Enter a grade: "))

#checks if grade is less than 0 or greater than 10 then set ans to null
if(grade < 0 or grade > 10):
    ans = ''
#checks if grade is less than 10 and greater than or equal to 8.5 then set ans to 'A'
elif(grade >= 8.5 and grade <= 10):
   ans = 'A'
 
#checks if grade is less than 8 and greater than or equal to 7.5 then set ans to 'B'
elif(grade >= 7.5 and grade <= 8):
    ans = 'B'

#checks if grade is less than 7 and greater than or equal to 6.5 then set ans to 'C'
elif(grade >= 6.5 and grade <= 7):
    ans = 'C'

#checks if grade is less than 6 and greater than or equal to 5.5 then set ans to 'D'
elif(grade >= 5.5 and grade <= 6):
    ans = 'D'

#checks if grade is less than 5.5 then set ans to 'D'
elif(grade < 5.5):
    ans = 'F'

#checks if ans is not null then print the grade in american style otherwise print the error msg
if(ans!= ''):
    print("Your grade in American style is: ",ans)
else:
    print("Please enter valid grade")
    

OUTPUT:


Related Solutions

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...
write a python program that inputs 10 integer values from the keyboard and then displays their...
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
for Python 3 Write a python program that Creates a list that has these values in...
for Python 3 Write a python program that Creates a list that has these values in this order, 'Python', 'JavaScript', and 'PHP' Define a displayMyClasses function that sorts the list and then displays each item on the list, one per line, in sorted order. Also, number the displayed list as shown in the "Running a Sample Program" shown below. Define a guessNext function that selects a random element from the list and returns it to the call of the function....
Question1; Write a c++ program that prints all natural numbers between 10(included) to 100(included) by the...
Question1; Write a c++ program that prints all natural numbers between 10(included) to 100(included) by the while loop. question2: Write a C++ program that prints all numbers between 10 to 1000 that are divisible by 5
Exercise #3 python Write a program that could evaluate the relationship between two values. User is...
Exercise #3 python Write a program that could evaluate the relationship between two values. User is to key in the two values, and it will be stored in variable, num1 and num2. The program will do a comparison between the two values. If num1 is greater than num2, a message will be display on screen to indicate that num1 is greater than num2. The program will also display appropriate messages when num2 is greater than num1; and num1 is equal...
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,...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the following requirements: Reads in a series of positive integers,  one number at a time;  and Calculate the product (multiplication) of all the integers less than 25,  and Calculate the sum (addition) of all the integers greater than or equal to 25. Use 0 as a sentinel value, which stops the input loop. [ If the input is 0 that means the end of the input list. ]...
Write a complete program in python to impute null values in a data frame with mean...
Write a complete program in python to impute null values in a data frame with mean and median . Please explain logic also because i am not understanding
write a program that finds the average of all positive, non-zero values found in a given...
write a program that finds the average of all positive, non-zero values found in a given array of doubles and prints that to the console. Any negative or zero values do not contribute to the average. The program should use the array provided in the code, and you may assume that it has already been populated with values. The results should be printed out to the console in the following format: “Average: ”<<average value>> Values denoted in “<< >>” represent...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT