Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahZabeen authored Oct 6, 2020
1 parent 7261e30 commit e6dc869
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions CGPA CALCULATOR.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import easygui\n",
"\n",
"class CGPA_CALC:\n",
" \n",
" name='Default'\n",
" department = 'Default'\n",
" Sem = 0\n",
" CGPA = 0\n",
" total_courses_completed = 0\n",
" cumulative_cg = 0\n",
" def __init__(self, name='Default', department='Default'):\n",
" CGPA_CALC.name = name ; CGPA_CALC.department = department \n",
" \n",
" def courses_and_cg(self,c):\n",
" CGPA_CALC.Sem+=1\n",
"\n",
" list_of_courses, list_of_cg = [] , []\n",
" avg = 0 ; total = 0\n",
" for i in range(0,len(c),2):\n",
" list_of_courses.append(c[i])\n",
" list_of_cg.append(c[i+1])\n",
" total += float(c[i+1])\n",
" avg = total/len(list_of_courses)\n",
" \n",
" CGPA_CALC.total_courses_completed += len(list_of_courses)\n",
" \n",
" CGPA_CALC.cumulative_cg += total\n",
" \n",
" CGPA_CALC.CGPA = CGPA_CALC.cumulative_cg / CGPA_CALC.total_courses_completed\n",
" \n",
" CGPA_CALC.CGPA = \"{:.2f}\".format(CGPA_CALC.CGPA)\n",
"\n",
" a=\"Semester: \"+str(CGPA_CALC.Sem)+'\\nName: '+self.name+'\\nDepartment: '+self.department \n",
" a=a+\"\\nCourses taken by \"+self.name+\": \"\n",
" \n",
" for i in range(0,len(list_of_courses),1):\n",
" if ( i == len(list_of_courses)-1 ):\n",
" a=a+list_of_courses[i]+\".\"\n",
" else:\n",
" a=a+list_of_courses[i]+\", \"\n",
" avg1=\"{:.2f}\".format(avg)\n",
" a=a+\"\\nGPA earned:\"+avg1+\"\\nCGPA:\"+str(CGPA_CALC.CGPA)\n",
" easygui.msgbox(a, title=\"Result\")\n",
" \n",
" def calculate(self,obj):\n",
" index=0\n",
" while 1:\n",
" \n",
" if index==0:\n",
" msg = \"Enter Your Course Codes and GPA\"\n",
" title = \"CGPA Calculator\"\n",
" fieldNames = ['Name','Department',\"Course 1\",'Course 1 GPA',\"Course 2\",'Course 2 GPA',\"Course 3\",'Course 3 GPA',\"Course 4\",'Course 4 GPA',\"Course 5\",'Course 5 GPA']\n",
" fieldValues = [] \n",
" fieldValues = easygui.multenterbox(msg,title, fieldNames)\n",
" while(\"\" in fieldValues) : \n",
" fieldValues.remove(\"\")\n",
" if fieldValues[0]=='STOP':\n",
" break\n",
" obj = CGPA_CALC(fieldValues[0],fieldValues[1])\n",
" obj.courses_and_cg(fieldValues[2:])\n",
" else:\n",
" msg = \"Enter Your Course Codes and GPA\"\n",
" title = \"CGPA Calculator\"\n",
" fieldNames = [\"Type 'STOP' to quit,\\n'CONTINUE' to Continue\",\"Course 1\",'Course 1 GPA',\"Course 2\",'Course 2 GPA',\"Course 3\",'Course 3 GPA',\"Course 4\",'Course 4 GPA',\"Course 5\",'Course 5 GPA']\n",
" fieldValues = [] \n",
" fieldValues = easygui.multenterbox(msg,title, fieldNames)\n",
" while(\"\" in fieldValues) : \n",
" fieldValues.remove(\"\")\n",
" if fieldValues[0]=='STOP':\n",
" break\n",
" obj.courses_and_cg(fieldValues[1:])\n",
" index+=1\n",
"a=CGPA_CALC()\n",
"a.calculate(a)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit e6dc869

Please sign in to comment.