Created
December 5, 2022 22:03
-
-
Save arikchakma/98b147a15801e0d8e9c4777e44746ba1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def gpa(*subs_nums): | |
| totalGpa = 0 | |
| for num in subs_nums: | |
| if num >= 90 and num <= 100: | |
| totalGpa += 4 | |
| elif num >= 85 and num <= 89: | |
| totalGpa += 3.70 | |
| elif num >= 80 and num <= 84: | |
| totalGpa += 3.30 | |
| elif num >= 75 and num <= 79: | |
| totalGpa += 3.00 | |
| elif num >= 70 and num <= 74: | |
| totalGpa += 2.70 | |
| elif num >= 65 and num <= 69: | |
| totalGpa += 2.30 | |
| elif num >= 60 and num <= 64: | |
| totalGpa += 2.00 | |
| elif num >= 55 and num <= 59: | |
| totalGpa += 1.70 | |
| elif num >= 50 and num <= 54: | |
| totalGpa += 1.30 | |
| elif num >= 45 and num <= 49: | |
| totalGpa += 1.00 | |
| else: | |
| totalGpa += 0 | |
| return totalGpa / len(subs_nums) | |
| def cgpa(): | |
| totalCgpa = 0 | |
| semestersCompleted = int(input("How many semesters have you completed? ")) | |
| for i in range(semestersCompleted): | |
| subjects = int(input("How many subjects did you take in semester " + str(i + 1) + "? ")) | |
| print("Enter your marks for semester " + str(i + 1) + ": ") | |
| marks = [] | |
| for j in range(subjects): | |
| marks.append(int(input("Enter your mark for subject " + str(j + 1) + ": "))) | |
| totalCgpa += gpa(*marks) | |
| return totalCgpa / semestersCompleted | |
| print("Your CGPA is: " + str(cgpa())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment