SlideShare a Scribd company logo
1 of 7
5/8/2017 MC303 A2_LAB 3
Creating GPA Calculatorusing
PythonProgramming Language
Nagiob Doma
ID# 6392
1. Program Description
- This program is written using Python Programming Language with Tkinter GUI to provide for a basic window
with simple event-driven functions. The program use Python Toolkit Interfaceas a GUI to provide a simple
operating window with basic functions. The functions on the GUI window consist of Checkbox labelled with
HD’s, D’s, CR’s, UP’s and P’s in which the user will use to click on to check/mark a student’s grades. There are
total of 8 units studied annually so we have about 40 Checkbox with a “result button” and an “exit button”
displayed on the window.
- Refer below for an overall snapshot view of the executed program.
2. The Algorithm
- The program simply use basic functions, a list, and conditional statements. Also, the commands for the
Tkinter for the GUI window are also used.
When the program is executed, a window pops up displaying the units and the grades as in figure above.
When a Checkbox is clicked, the value that is assign to that checkbox is appended to an empty list. After all
the checkboxes are marked, all the values will be appended to the empty list. Thus, the empty list is then used
by a function called “calc”. This function(calc) gets the sum of the list, divide the sum with the total number of
units then use the “if statement” to categorised the results.
After all the checked button has checked, the result button is pressed. Hence, the result button activates the
“calc” function to execute the calculation and produce the result. The result is then displayed on the right side
of the GUI window.
3. Code for the Program
- #Simple GPA Calculator
- #Aurthor: Nagiob Doma (ID6392)
-
- from tkinter import *
- import math
-
- re = [] #This is an empty list that cater for all the values for the grades
-
-
- '''This are the functions that append valuse to the empty list above when a checkbox is clicked'''
- def HD():
- re.append(4.0)
- def D():
- re.append(3.0)
- def CR():
- re.append(2.5)
- def UP():
- re.append(2.0)
- def P():
- re.append(1.0)
-
-
-
- #This is the main function that calculates the GPA and outputs the result on the screen
-
- def calc():
- e = (sum(re))/8
-
- if 1.5 <=e<=2.4:
- label1 = Label(root, text = "The GPA result is %1.2f and the student is in %s Category" %(e,"Self
Sponsor"),font = 'Bold').grid(row=4, column=7)
-
- if 2.5 <=e<= 3.4:
- label2 = Label(root, text = "The GPA result is %1.2f and the student is in %s Category" %(e,"HECAS"),font
= 'Bold').grid(row=4, column=7)
-
-
- if 3.5 <=e<=4.0:
- label3 = Label(root, text = "The GPA result is %1.2f and the student is in %s Category" %(e,"AES"),font =
'Bold').grid(row=4, column=7)
-
- if e<1.5:
- f = e
- label3 = Label(root, text = "The Student Fails because the GPA is %1.2f" %e,font = 'Bold').grid(row=4,
column=7)
-
-
- '''TKinter commands for the User Interface'''
- root = Tk()
- root.title('GPA Calculator')
- root.geometry('900x400')
-
- label1 = Label(root, text = 'Enter the HDs, Ds, CRs, UPs and Ps', font='Italic').grid(row=0, column=7)
- '''label2 = Label(root, text = 'Unit 1').grid(row=1, column=0)'''
- label3 = Label(root, text = 'Unit 1',font='Italic').grid(row=1, column=0)
- label4 = Label(root, text = 'Unit 2',font='Italic').grid(row=2, column=0)
- label5 = Label(root, text = 'Unit 3',font='Italic').grid(row=3, column=0)
- label6 = Label(root, text = 'Unit 4',font='Italic').grid(row=4, column=0)
- label7 = Label(root, text = 'Unit 5',font='Italic').grid(row=5, column=0)
- label8 = Label(root, text = 'Unit 6',font='Italic').grid(row=6, column=0)
- label9 = Label(root, text = 'Unit 7',font='Italic').grid(row=7, column=0)
- label0 = Label(root, text = 'Unit 8',font='Italic').grid(row=8, column=0)
-
- chbut1 = Checkbutton(root, text = 'HD',command = HD).grid(row=1, column=1)
- chbut2 = Checkbutton(root, text = 'D',command = D).grid(row=1, column=2)
- chbut3 = Checkbutton(root, text = 'CR',command = CR).grid(row=1, column=3)
- chbut4 = Checkbutton(root, text = 'UP',command = UP).grid(row=1, column=4)
- chbut5 = Checkbutton(root, text = 'P',command = P).grid(row=1, column=5)
-
- chbut6 = Checkbutton(root, text = 'HD',command = HD).grid(row=2, column=1)
- chbut7 = Checkbutton(root, text = 'D',command = D).grid(row=2, column=2)
- chbut8 = Checkbutton(root, text = 'CR',command = CR).grid(row=2, column=3)
- chbut9 = Checkbutton(root, text = 'UP',command = UP).grid(row=2, column=4)
- chbut10 = Checkbutton(root, text = 'P',command = P).grid(row=2, column=5)
-
- chbut11 = Checkbutton(root, text = 'HD',command = HD).grid(row=3, column=1)
- chbut12 = Checkbutton(root, text = 'D',command = D).grid(row=3, column=2)
- chbut13 = Checkbutton(root, text = 'CR',command = CR).grid(row=3, column=3)
- chbut14 = Checkbutton(root, text = 'UP',command = UP).grid(row=3, column=4)
- chbut15 = Checkbutton(root, text = 'P',command = P).grid(row=3, column=5)
-
- chbut16 = Checkbutton(root, text = 'HD',command = HD).grid(row=4, column=1)
- chbut17 = Checkbutton(root, text = 'D',command = D).grid(row=4, column=2)
- chbut18 = Checkbutton(root, text = 'CR',command = CR).grid(row=4, column=3)
- chbut19 = Checkbutton(root, text = 'UP',command = UP).grid(row=4, column=4)
- chbut20 = Checkbutton(root, text = 'P',command = P).grid(row=4, column=5)
-
- chbut21 = Checkbutton(root, text = 'HD',command = HD).grid(row=5, column=1)
- chbut22 = Checkbutton(root, text = 'D',command = CR).grid(row=5, column=2)
- chbut23 = Checkbutton(root, text = 'CR',command = CR).grid(row=5, column=3)
- chbut24 = Checkbutton(root, text = 'UP',command = UP).grid(row=5, column=4)
- chbut25 = Checkbutton(root, text = 'P',command = P).grid(row=5, column=5)
-
- chbut26 = Checkbutton(root, text = 'HD',command = HD).grid(row=6, column=1)
- chbut27 = Checkbutton(root, text = 'D',command = CR).grid(row=6, column=2)
- chbut28 = Checkbutton(root, text = 'CR',command = CR).grid(row=6, column=3)
- chbut29 = Checkbutton(root, text = 'UP',command = UP).grid(row=6, column=4)
- chbut30 = Checkbutton(root, text = 'P',command = P).grid(row=6, column=5)
-
- chbut31 = Checkbutton(root, text = 'HD',command = HD).grid(row=7, column=1)
- chbut32 = Checkbutton(root, text = 'D',command = D).grid(row=7, column=2)
- chbut33 = Checkbutton(root, text = 'CR',command = CR).grid(row=7, column=3)
- chbut34= Checkbutton(root, text = 'UP',command = UP).grid(row=7, column=4)
- chbut35 = Checkbutton(root, text = 'P',command = P).grid(row=7, column=5)
-
- chbut36 = Checkbutton(root, text = 'HD',command = HD).grid(row=8, column=1)
- chbut37 = Checkbutton(root, text = 'D',command = D).grid(row=8, column=2)
- chbut38 = Checkbutton(root, text = 'CR',command = CR).grid(row=8, column=3)
- chbut39 = Checkbutton(root, text = 'UP',command = UP).grid(row=8, column=4)
- chbut40 = Checkbutton(root, text = 'P',command = P).grid(row=8, column=5)
-
-
-
-
-
- #This is the Result button that execute the calc function
- but1 = Button(root, text = "result", font= "Italic", command = calc).grid(row=10,column=7)
-
- but1 = Button(root, text = "EXIT", command = exit).grid(row=11, column=7) #Exit button
-
- root.mainloop()
4. Test Result/ Test casesfor the program
References
django. (2016). The Tkinter Checkbutton Widget. Retrieved from effbot.org:
http://www.effbot.org/tkinterbook/checkbutton.htm
Tutorials Point. (2017). Retrieved from www.tutorialspoint.com:
https://www.tutorialspoint.com/python/python_gui_programming.htm

More Related Content

What's hot

Mc amca04919 plsql programs
Mc amca04919 plsql programsMc amca04919 plsql programs
Mc amca04919 plsql programs
Ashwin Kumar
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Alex Penso Romero
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
ritu1806
 

What's hot (20)

Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Mc amca04919 plsql programs
Mc amca04919 plsql programsMc amca04919 plsql programs
Mc amca04919 plsql programs
 
Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)
 
Writeable CTEs: The Next Big Thing
Writeable CTEs: The Next Big ThingWriteable CTEs: The Next Big Thing
Writeable CTEs: The Next Big Thing
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
 
PHP for Python Developers
PHP for Python DevelopersPHP for Python Developers
PHP for Python Developers
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
Closure, Higher-order function in Swift
Closure, Higher-order function in SwiftClosure, Higher-order function in Swift
Closure, Higher-order function in Swift
 
Clang2018 class3
Clang2018 class3Clang2018 class3
Clang2018 class3
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Climbing the Abstract Syntax Tree (Forum PHP 2017)
Climbing the Abstract Syntax Tree (Forum PHP 2017)Climbing the Abstract Syntax Tree (Forum PHP 2017)
Climbing the Abstract Syntax Tree (Forum PHP 2017)
 
Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)Climbing the Abstract Syntax Tree (PHP UK 2018)
Climbing the Abstract Syntax Tree (PHP UK 2018)
 
Symfony2 - extending the console component
Symfony2 - extending the console componentSymfony2 - extending the console component
Symfony2 - extending the console component
 
linieaire regressie
linieaire regressielinieaire regressie
linieaire regressie
 
Cpl
CplCpl
Cpl
 

Similar to Assignment 2 lab 3 python gpa calculator

Program 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdfProgram 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdf
ezhilvizhiyan
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdf
pasqualealvarez467
 
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docxE2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docx
jacksnathalie
 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
Yashpatel821746
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revision
afsheenfaiq2
 

Similar to Assignment 2 lab 3 python gpa calculator (20)

RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
 
Program 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdfProgram 1 (Practicing an example of function using call by referenc.pdf
Program 1 (Practicing an example of function using call by referenc.pdf
 
Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptx
 
Produce nice outputs for graphical, tabular and textual reporting in R-Report...
Produce nice outputs for graphical, tabular and textual reporting in R-Report...Produce nice outputs for graphical, tabular and textual reporting in R-Report...
Produce nice outputs for graphical, tabular and textual reporting in R-Report...
 
I really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdfI really need help with this Assignment Please in C programming not .pdf
I really need help with this Assignment Please in C programming not .pdf
 
Regression and Classification with R
Regression and Classification with RRegression and Classification with R
Regression and Classification with R
 
R basics
R basicsR basics
R basics
 
Python programming workshop session 4
Python programming workshop session 4Python programming workshop session 4
Python programming workshop session 4
 
Char word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECTChar word counter in Python with simple gui - PROJECT
Char word counter in Python with simple gui - PROJECT
 
The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docxE2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docx
 
The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196
 
How to generate a 100+ page website using parameterisation in R
How to generate a 100+ page website using parameterisation in RHow to generate a 100+ page website using parameterisation in R
How to generate a 100+ page website using parameterisation in R
 
R Language
R LanguageR Language
R Language
 
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
 
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
 
Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016Introduction to R Short course Fall 2016
Introduction to R Short course Fall 2016
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revision
 

Recently uploaded

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

Assignment 2 lab 3 python gpa calculator

  • 1. 5/8/2017 MC303 A2_LAB 3 Creating GPA Calculatorusing PythonProgramming Language Nagiob Doma ID# 6392
  • 2. 1. Program Description - This program is written using Python Programming Language with Tkinter GUI to provide for a basic window with simple event-driven functions. The program use Python Toolkit Interfaceas a GUI to provide a simple operating window with basic functions. The functions on the GUI window consist of Checkbox labelled with HD’s, D’s, CR’s, UP’s and P’s in which the user will use to click on to check/mark a student’s grades. There are total of 8 units studied annually so we have about 40 Checkbox with a “result button” and an “exit button” displayed on the window. - Refer below for an overall snapshot view of the executed program. 2. The Algorithm - The program simply use basic functions, a list, and conditional statements. Also, the commands for the Tkinter for the GUI window are also used. When the program is executed, a window pops up displaying the units and the grades as in figure above. When a Checkbox is clicked, the value that is assign to that checkbox is appended to an empty list. After all the checkboxes are marked, all the values will be appended to the empty list. Thus, the empty list is then used by a function called “calc”. This function(calc) gets the sum of the list, divide the sum with the total number of units then use the “if statement” to categorised the results. After all the checked button has checked, the result button is pressed. Hence, the result button activates the “calc” function to execute the calculation and produce the result. The result is then displayed on the right side of the GUI window. 3. Code for the Program - #Simple GPA Calculator - #Aurthor: Nagiob Doma (ID6392) - - from tkinter import * - import math - - re = [] #This is an empty list that cater for all the values for the grades - - - '''This are the functions that append valuse to the empty list above when a checkbox is clicked''' - def HD():
  • 3. - re.append(4.0) - def D(): - re.append(3.0) - def CR(): - re.append(2.5) - def UP(): - re.append(2.0) - def P(): - re.append(1.0) - - - - #This is the main function that calculates the GPA and outputs the result on the screen - - def calc(): - e = (sum(re))/8 - - if 1.5 <=e<=2.4: - label1 = Label(root, text = "The GPA result is %1.2f and the student is in %s Category" %(e,"Self Sponsor"),font = 'Bold').grid(row=4, column=7) - - if 2.5 <=e<= 3.4: - label2 = Label(root, text = "The GPA result is %1.2f and the student is in %s Category" %(e,"HECAS"),font = 'Bold').grid(row=4, column=7) - - - if 3.5 <=e<=4.0: - label3 = Label(root, text = "The GPA result is %1.2f and the student is in %s Category" %(e,"AES"),font = 'Bold').grid(row=4, column=7) - - if e<1.5: - f = e - label3 = Label(root, text = "The Student Fails because the GPA is %1.2f" %e,font = 'Bold').grid(row=4, column=7) - - - '''TKinter commands for the User Interface''' - root = Tk() - root.title('GPA Calculator') - root.geometry('900x400') - - label1 = Label(root, text = 'Enter the HDs, Ds, CRs, UPs and Ps', font='Italic').grid(row=0, column=7) - '''label2 = Label(root, text = 'Unit 1').grid(row=1, column=0)''' - label3 = Label(root, text = 'Unit 1',font='Italic').grid(row=1, column=0) - label4 = Label(root, text = 'Unit 2',font='Italic').grid(row=2, column=0) - label5 = Label(root, text = 'Unit 3',font='Italic').grid(row=3, column=0) - label6 = Label(root, text = 'Unit 4',font='Italic').grid(row=4, column=0) - label7 = Label(root, text = 'Unit 5',font='Italic').grid(row=5, column=0) - label8 = Label(root, text = 'Unit 6',font='Italic').grid(row=6, column=0) - label9 = Label(root, text = 'Unit 7',font='Italic').grid(row=7, column=0) - label0 = Label(root, text = 'Unit 8',font='Italic').grid(row=8, column=0) - - chbut1 = Checkbutton(root, text = 'HD',command = HD).grid(row=1, column=1)
  • 4. - chbut2 = Checkbutton(root, text = 'D',command = D).grid(row=1, column=2) - chbut3 = Checkbutton(root, text = 'CR',command = CR).grid(row=1, column=3) - chbut4 = Checkbutton(root, text = 'UP',command = UP).grid(row=1, column=4) - chbut5 = Checkbutton(root, text = 'P',command = P).grid(row=1, column=5) - - chbut6 = Checkbutton(root, text = 'HD',command = HD).grid(row=2, column=1) - chbut7 = Checkbutton(root, text = 'D',command = D).grid(row=2, column=2) - chbut8 = Checkbutton(root, text = 'CR',command = CR).grid(row=2, column=3) - chbut9 = Checkbutton(root, text = 'UP',command = UP).grid(row=2, column=4) - chbut10 = Checkbutton(root, text = 'P',command = P).grid(row=2, column=5) - - chbut11 = Checkbutton(root, text = 'HD',command = HD).grid(row=3, column=1) - chbut12 = Checkbutton(root, text = 'D',command = D).grid(row=3, column=2) - chbut13 = Checkbutton(root, text = 'CR',command = CR).grid(row=3, column=3) - chbut14 = Checkbutton(root, text = 'UP',command = UP).grid(row=3, column=4) - chbut15 = Checkbutton(root, text = 'P',command = P).grid(row=3, column=5) - - chbut16 = Checkbutton(root, text = 'HD',command = HD).grid(row=4, column=1) - chbut17 = Checkbutton(root, text = 'D',command = D).grid(row=4, column=2) - chbut18 = Checkbutton(root, text = 'CR',command = CR).grid(row=4, column=3) - chbut19 = Checkbutton(root, text = 'UP',command = UP).grid(row=4, column=4) - chbut20 = Checkbutton(root, text = 'P',command = P).grid(row=4, column=5) - - chbut21 = Checkbutton(root, text = 'HD',command = HD).grid(row=5, column=1) - chbut22 = Checkbutton(root, text = 'D',command = CR).grid(row=5, column=2) - chbut23 = Checkbutton(root, text = 'CR',command = CR).grid(row=5, column=3) - chbut24 = Checkbutton(root, text = 'UP',command = UP).grid(row=5, column=4) - chbut25 = Checkbutton(root, text = 'P',command = P).grid(row=5, column=5) - - chbut26 = Checkbutton(root, text = 'HD',command = HD).grid(row=6, column=1) - chbut27 = Checkbutton(root, text = 'D',command = CR).grid(row=6, column=2) - chbut28 = Checkbutton(root, text = 'CR',command = CR).grid(row=6, column=3) - chbut29 = Checkbutton(root, text = 'UP',command = UP).grid(row=6, column=4) - chbut30 = Checkbutton(root, text = 'P',command = P).grid(row=6, column=5) - - chbut31 = Checkbutton(root, text = 'HD',command = HD).grid(row=7, column=1) - chbut32 = Checkbutton(root, text = 'D',command = D).grid(row=7, column=2) - chbut33 = Checkbutton(root, text = 'CR',command = CR).grid(row=7, column=3) - chbut34= Checkbutton(root, text = 'UP',command = UP).grid(row=7, column=4) - chbut35 = Checkbutton(root, text = 'P',command = P).grid(row=7, column=5) - - chbut36 = Checkbutton(root, text = 'HD',command = HD).grid(row=8, column=1) - chbut37 = Checkbutton(root, text = 'D',command = D).grid(row=8, column=2) - chbut38 = Checkbutton(root, text = 'CR',command = CR).grid(row=8, column=3) - chbut39 = Checkbutton(root, text = 'UP',command = UP).grid(row=8, column=4) - chbut40 = Checkbutton(root, text = 'P',command = P).grid(row=8, column=5) - - - - - - #This is the Result button that execute the calc function - but1 = Button(root, text = "result", font= "Italic", command = calc).grid(row=10,column=7) -
  • 5. - but1 = Button(root, text = "EXIT", command = exit).grid(row=11, column=7) #Exit button - - root.mainloop() 4. Test Result/ Test casesfor the program
  • 6.
  • 7. References django. (2016). The Tkinter Checkbutton Widget. Retrieved from effbot.org: http://www.effbot.org/tkinterbook/checkbutton.htm Tutorials Point. (2017). Retrieved from www.tutorialspoint.com: https://www.tutorialspoint.com/python/python_gui_programming.htm