Question

In: Computer Science

Write a program that translates a letter grade into a number grade. Letter grades are A,...

  1. Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts

Enter a Letter grade: B-

The numeric value is 2.7

  1. Your code with comments
  2. A screenshot of the execution

Test Cases:

            B-   (should print 2.7)

            A+ (should print 4.0)

            B+ (should print 3.3)

            C    (should print 2.0)

            F+ (should print 0.0)

            G    (should print “no such grade”)

Python, keep it simple

Solutions

Expert Solution

Hi,

Hope you are doing fine. I have coded the above question in python. Since you have mentioned to keep it simpke, I have tried to make it as easy as possible. The logic of the code is pretty straighforward and the code is explained through comments that have been highlighted in bold. Also please have a look at the code snippet and out put to get a better understanding about the indentation and execution of the program.

Program:

#taking input from user with a prompt to enter the letter grade and storing it in grade
grade=input("Enter a Letter grade: ")

#conversion is a dictionary that store all the possible coversion of the grades in the form of key value pairs. It has all the grades given in the question
#Value of each grade is a floating point number that are as per the conditions mentioned in the question

conversion={'A':4.0,'A+':4.0,'A-':3.7,
'B':3.0,'B+':3.3,'B-':2.7,
'C':2.0,'C+':2.3,'C-':1.7,
'D':1.0,'D+':1.3,'D-':0.7,
'F':0.0,'F+':0.0,'F-':0.0}

#if grade entered by the user is not present in the dictionary as a key then
if grade not in conversion.keys():
#we print that there is no such grade
print("no such grade")

#else if the grade entered is present in the dictionary then
else:
#the value at that key is printed which would be its numeric conversion.
print("The numeric value is ",conversion[grade])

Executable code snippet from jupyter notebook:

Sample outputs of given test cases:


Related Solutions

write a Java program Write a program to assign a letter grade according to the following...
write a Java program Write a program to assign a letter grade according to the following scheme: A: total score >= 90 B: 80 <= total score < 90 C: 70 <= total score < 80 D: 60 <= total score < 70 F: total score < 60 Output - the student's total score (float, 2 decimals) and letter grade Testing - test your program with the following input data: test1 = 95; test2 = 80; final = 90; assignments...
Write a program that will calculate numerical and letter grades for a student and output a...
Write a program that will calculate numerical and letter grades for a student and output a report: The information will be in the provided data file studentGrades.txt. The data file consists of several rows of data containing a student name and information for 3 types of assignments: First Name, Last Name, number of homework grades, values for homework grades, percentage of total grade, number of program grades, values for program grades, percental of total grade, number of ex-am grades, values...
Write a program that will calculate numerical and letter grades for a student and output a...
Write a program that will calculate numerical and letter grades for a student and output a report: The information will be in the provided data file studentGrades.txt. The data file consists of several rows of data containing a student name and information for 3 types of assignments: First Name, Last Name, number of homework grades, values for homework grades, percentage of total grade, number of program grades, values for program grades, percental of total grade, number of ex-am grades, values...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade point average (GPA) Each A is worth 4 points. Each B is worth 3 points. Each C is worth 2 points. Each D is worth 1 point, and Each F is worth 0 points. The total quality points earned is the sum of the product of letter grade points and associated course credit hours. The GPA is the quotient of the quality points divided...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this course (CSC100 online) based on three user inputs. This program should begin by printing the title of the application (program) and a brief description of what it does. (Note: this is NOT the same as the program prolog: a prolog is much more detailed, has required elements, and is intended for other programmers reading the cpp file. The title and description displayed by the...
Topics Loops while Statement Description Write a program that computes the letter grades of students in...
Topics Loops while Statement Description Write a program that computes the letter grades of students in a class from knowing their scores in a test. A student test score varies from 0 to 100. For a student, the program first asks the student’s name and the student’s test score. Then, it displays the student name, the test score and the letter grade. It repeats this process for each student. The user indicates the end of student data by entering two...
Create a program that translates English into Pig Latin. The function will take the first letter...
Create a program that translates English into Pig Latin. The function will take the first letter of each word in the sentence only if it’s a not a vowel, and place it at the end of the word followed by “ay”. Your program must be case ​ins​ ensitive. You must write the functiontranslate() ​that takes in a single English word and ​returns​ its Pig Latin translation. Remembertranslatemusttake​onlyonewordasinput.​ ############################################################# # translate() takes a single english word translates it to #pig latin...
Create an Java application that uses a class to convert number grades to letter grades and...
Create an Java application that uses a class to convert number grades to letter grades and another class for data validation. Specifications The Grade class should have only one Instance Variable of type int. Use a class named Grade to store the data for each grade. This class should include these three methods:   public void setNumber(int number)   public int getNumber()   public String getLetter() The Grade class should have two constructors. The first one should accept no parameters and set the...
JAVA Write a program that translates a user-input floating-point number between 0 and 4 into the...
JAVA Write a program that translates a user-input floating-point number between 0 and 4 into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B–. Break ties in favor of the better grade; for example 2.85 should be a B. NOTE: Your implementation must include the definition/implementation and use/calling of the method numberGradeToLetterGrade that is passed a double numeric grade to its parameter variable, and returns the...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT