Neler yeni

Python CGPA-GPA Calculator

Samurai Jack

Bronz
Katılım
13 Ağu 2023
Mesajlar
1
Tepkime puanı
2
Puanları
20
Üniversite genel ve dönemlik Not ortalamasını hesaplayan çok basic bir program. Yeni başlayanlar için güzel, öğretici bir proje olabilir.

Türkiye de en fazla kullanılan Harf notu sistemine göre hesaplar. ( AA, BA, BB...). Değiştirip geliştirebilirsiniz.

Python:
import time


print("Welcome to GPA / CGPA Calculator! ")


def gpaCalculator():

  #list1 = []
  total1 = 0 # Kredi ile Harf notu çarpımlarının toplamı
  total2 = 0 # Kredilerin Toplamı

  lessonNumber = int(input("How Many Lessons Do You Have?: "))
  #for ch in range(0,lessonNumber):
    #lessonName = input("Enter Your "+str(ch+1)+". lesson name: ")
    #list3.append(lessonName)

  for x in range(0,lessonNumber):
    i,j = input("Enter Your "+str(x+1)+". Lesson's Letter Grade and Credit: ").split()

    j = int(j)
    i = i.upper()

    if i == "AA":
        i = j*4
    elif i == "BA":
      i = j*(3.5)
    elif i == "BB":
      i = j*(3.0)
    elif i == "CB":
      i = j*(2.50)
    elif i == "CC":
      i = j*(2.0)
    elif i == "DC":
      i = j*(1.50)
    elif i == "DD":
      i = j*(1.0)
    else:
      i = 0

    total1 = total1 + i
    total2 = total2 + j
 

  totalGpa = total1 / total2

  print("Your GPA is: ", format(totalGpa,'.2f'))

def cgpaCalculator():

  list1 = []
  total3 = 0
  total4 = 0

  semesterNumber = int(input("Which semester do you in: "))
  for i in range(0,semesterNumber-1):
    semesterGPA = float(input("Enter Your "+str(i+1)+". semester GPA: "))
    list1.append(semesterGPA)

  print("Lets Calculate your "+str(semesterNumber)+". Semester GPA to Find CGPA")

  lessonNumber1 = int(input("How Many Lessons Do You Have in your "+str(semesterNumber)+". Semester?: "))


  for i in range(0,lessonNumber1):
    m,n = input(f"Enter Your {i+1}. Lesson's Letter Grade and Credit: ").split()

    n = int(n)
    m = m.upper()
    if m == "AA":
        m = n*4
    elif m == "BA":
      m = n*(3.50)
    elif m=="BB":
      m = n*(3.0)
    elif m == "CB":
      m = n*(2.50)
    elif m == "CC":
      m = n*(2.00)
    elif m == "DC":
      m = n*(1.50)
    elif m == "DD":
      m = n*(1.0)
    else:
      m = 0

    total3 = total3 + m
    total4 = total4 + n


  totalGpa1 = total3 / total4  # Son dönemin ortalaması

  total5 = 0 # Tüm dönemlerin ortalamasının toplamı

  for i in range(0,len(list1)):
    total5 = total5 + list1[i]

  total5 = total5 + totalGpa1
 
  totalCgpa = total5 / semesterNumber

  print("Your "+str(semesterNumber)+". Semester GPA is: ", format(totalGpa1,'.2f'))
  print("Your CGPA is: ", format(totalCgpa,'.2f'))

def calculateAgain():
    choice1 = input("\nDo you want to Calculate Again (Yes/No)?: ")
    choice1 = choice1.upper()
    if choice1 == "YES":
        choice = input("\nType 1 for GPA,Type 0 for GPA-CGPA: ")

        while (choice.isdigit() == False) or (choice != '1' and choice != '0'):
          print("\nPlease enter 1 or 0")
          choice = input("\nType 1 for GPA,Type 0 for GPA/CGPA: ")

        else:
          if choice == '1':
            gpaCalculator()
            calculateAgain()
          elif choice == '0':
            cgpaCalculator()
            calculateAgain()


choice = input("\nType 1 for GPA,Type 0 for GPA-CGPA: ")

while (choice.isdigit() == False) or (choice != '1' and choice != '0'):
  print("\nPlease enter 1 or 0")
  choice = input("\nType 1 for GPA,Type 0 for GPA/CGPA: ")

else:
  if choice == '1':
    gpaCalculator()
    calculateAgain()
  elif choice == '0':
    cgpaCalculator()
    calculateAgain()

print("Good Bye!")

time.sleep(5)
 

                                                                                                  

GouLish

Yönetici
Admin
Katılım
28 Ocak 2022
Mesajlar
67
Tepkime puanı
108
Puanları
350
Eline sağlık güzel bir paylaşım olmuş :)
 

                                                                                                  
Üst Alt