In: Computer Science
For Python:
In this assignment you are asked to write a Python program to determine the Academic Standing of a studentbased on their CGPA. The program should do the following:
To calculate CGPA use the formula:
CGPA = (quality points * credit hours) / credit hours
Each subject is worth of 3 credit hours.
Grade |
Quality Points |
A |
4.0 |
B |
3.0 |
C |
2.0 |
D |
1.0 |
F |
0.0 |
CGPA |
Academic Standing |
2.00 – 4.00 |
Good |
1.75 – 1.99 |
Warning |
1.00 – 1.74 |
Probation |
0.00 – 0.99 |
Suspension |
Enter student’s name:
Enter student’s major:
Enter the grade for subject1 (A, B, C, D, F):
Enter the grade for subject2 (A, B, C, D, F)::
Enter the grade for subject3 (A, B, C, D, F)::
#Skip a couple of lines
Student Name: #All letters should be in uppercase
Major: #The major should be displayed in title case
CGPA:
Academic Standing:
The grades entered should belong to the set {A, B, C, D, F}. After the prompt, check to be sure they are one of those. Print (display) an error message if they are not and do not prompt the user for the grades again. The program ends.
Sample Output:
Enter student’s name: james smith
Enter student’s major: Electrical Engineering
Enter the grade for subject1 (A, B, C, D, F): A
Enter the grade for subject2 (A, B, C, D, F): B
Enter the grade for subject3 (A, B, C, D, F): A
Student Name: JAMES SMITH
Major: Electrical Engineering
CGPA: 3.76
Academic Standing: Good
#####please refer pic for indentations(tabs)
import math
import sys
name=input("Enter student's name:")
major=input("Enter student's major:")
grades=[0]*3
dict = {"A": 4,"B":3,"C":2,"D":1,"F":0}
for i in range(3):
inp=input('Enter the grade for subject1 (A, B, C, D, F):')
if(inp in dict):
grades[i]=dict[inp]
else:
sys.exit("wrong grade")
g=round(sum(grades)/len(grades),2)
print("student Name:",name.upper())
print("Major:", major)
print("CGPA:",g)
print("Academic standing:",end="")
if (g>=2 and g<=4):
print("Good")
elif (g>=1.75 and g<=1.99):
print("Warning")
elif (g>=1.00 and g<=1.74):
print("Probation")
elif (g>=0.00 and g<=0.99):
print("Suspension")