In: Computer Science
Write a program that prompts the user for a grade (0-100), and asks if the student is a graduate student or not. (Y/N).
#----------------------main.py------------------------------#
grade = input("Enter the grades(0-100): ");
grade = int(grade);
while grade < 0 or grade > 100 :
grade = input("Enter valid grade: ");
grade = int(grade);
gradOption = input("The student is a graduate student or not.
(Y/N):");
gradOption = gradOption.upper();
if (gradOption == "Y"):
grade = (int) (grade - grade * 0.1);
#set letter grade
letterGrade = "";
if (grade < 100 and grade >= 90) :
letterGrade = "A";
elif (grade < 90 and grade >= 80):
letterGrade = "B";
elif (grade < 80 and grade >= 70):
letterGrade = "C";
elif (grade < 70 and grade >= 60):
letterGrade = "D";
else:
letterGrade = "F";
print("Your letter grade is: ",letterGrade);
#print feedback
if letterGrade == "A" or letterGrade == "B" :
print("Excellent.");
elif letterGrade == "C" or letterGrade == "D":
print("Could Improve.");
else :
print("Need Work.");
/**********************output*******************/
Enter the grades(0-100): -45
Enter valid grade: 101
Enter valid grade: 98
The student is a graduate student or not. (Y/N):Y
Excellent.
Please let me know if you have any doubt or modify the answer, Thanks :)