Skip to content

Instantly share code, notes, and snippets.

@sairam4123
Last active May 15, 2025 08:39
Show Gist options
  • Save sairam4123/105e1a7722e7f831328924c87fab514e to your computer and use it in GitHub Desktop.
Save sairam4123/105e1a7722e7f831328924c87fab514e to your computer and use it in GitHub Desktop.
num_sem = 3
credits = [22, 26, 23.5]
total_gp = 0
total_credits = sum(credits)
for i in range(num_sem):
gpa = float(input(f"Enter gpa for sem {i+1}:"))
gp = gpa * credits[i]
total_gp += gp
print(f"Total CGPA: {total_gp/total_credits:.2f}")
sm = {
"O": 10,
"A+": 9,
"A": 8,
"B+": 7,
"B": 6,
"C": 5,
"U": 0
}
semester = 3
sub_credits_1 = {
"HS3152": 3,
"MA3151": 4,
"PH3151": 3,
"CY3151": 3,
"GE3151": 3,
"GE3152": 1,
"GE3171": 2,
"BS3171": 2,
"GE3172": 1,
}
sub_credits_2 = {
"HS3252": 2,
"MA3251": 4,
"PH3256": 3,
"BE3251": 3,
"GE3251": 4,
"CS3251": 3,
"GE3252": 1,
"GE3271": 2,
"CS3271": 2,
"GE3272": 2,
}
sub_credits_3 = {
"MA3354": 4,
"CS3351": 4,
"CS3352": 3,
"CD3291": 3,
"CS3391": 3,
"CD3281": 2,
"CS3381": 1.5,
"CS3361": 2,
"GE3361": 1
}
grade_scored = []
scored_credits = 0
sem_wise_credits = {
1: sub_credits_1,
2: sub_credits_2,
3: sub_credits_3
}
sub_credits = sem_wise_credits[semester]
total_credits = sum(sub_credit for sub_credit in sub_credits.values())
print(total_credits)
for sub in sub_credits:
credit = sub_credits[sub]
grade = input(f"Enter your grade for {sub}: ")
gp = sm[grade]
scored_credits += credit * gp
print(f"GPA: {(scored_credits/total_credits):.2f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment