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
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 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...
Suppose grades = [9, 7, 7, 10, 3, 9, 6, 6, 2] Write in Python An...
Suppose grades = [9, 7, 7, 10, 3, 9, 6, 6, 2] Write in Python An expression that evaluates to the number of 7 grades A statement that changes the last grade to 4 An expression that evaluates to the maximum grade A statement that sorts the list grades An expression that evaluates to the average grade
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD, the application should display 555-438-3663. This is my code, but I cannot figure out where to go from here. #set new number new_number = "" #split number split_num = phone.split("-") for char in split_num[1:2]:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT