Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Python Report PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Page|1

SIX WEEKS SUMMER TRAINING


REPORT
on

PYTHON

Submitted by
Shubham Kaushik

11702234
B.tech Hons. (Computer Science)

School of Computer Science &


Engineering

Lovely Professional University, Phagwara


Page|2

DECLARATION

I hereby declare that I have completed my six weeks summer training at Telcocrats
from 01 June 2019 to 12 July 2019. I have declare that I have worked with full
dedication during these six weeks of training and my learning outcomes fulfill the
requirements of training for the award of degree of B.tech, Lovely Professional
University, Phagwara.

Shubham Kaushik
11702234

Date: 03 August 2019


Page|3

Acknowledgement

It is our proud privilege and duty to acknowledge the kind of help and guidance received
from several people in preparation of this report. It would not have been possible to
prepare this report in this form without their valuable help, cooperation and guidance.
First and foremost, I wish to record my sincere gratitude to the faculties of Lovely
Professional University for giving me this opportunity to learn advanced this
technology and develop new skills.
I would like to give my sincere gratitude to the offline training website “Telcocrats” for
giving me this chance to assimilate this developing and widely used technology. The
summer training on “Python” was very helpful in gaining the necessary knowledge in
this emerging technology . The contribution and technical support of the Telcocrats
team in preparing this report are greatly acknowledged.
Last but not the least, I wish to thank my parents for financing our studies in this
college as well as for constantly encouraging me to learn and grow. Their personal
sacrifice in providing this opportunity to learn this program is gratefully acknowledged.
Page|4

Certificate
Page|5

Table of Contents
Topics Page no.

1 . Introduction to Python and its Installation 7

2. Using Variables in Python 12

3. Basics of Programming in Python 23

4. Principles of Object-oriented Programming (OOP) 34

5. Developing a GUI with PyQT

6. Testing

7. Gantt chart 41

8. Coding

9. Conclusion 46
Page|6

Module – 1
IntroductionTo Python And Its Installation

Introduction
Python is an interpreted high-level programming language for general-purpose
programming. Created by Guido van Rossumand first released in 1991, Python has a
design philosophy that emphasizes code readability, notably using significant
whitespace. It provides constructs that enable clear programming on both small and
large scales.

Python supports multiple programming paradigms, including object-oriented,


imperative and functional programming or procedural styles. It features a dynamic
type system and automatic memory management and has a large and
comprehensive standard library. Python interpreters are available for installation on
many operating systems, allowing Python code execution on a wide variety of
systems.

Python interpreters are available for many operating systems. CPython, the
reference implementation of Python, is open source software and has a community-
based development model, as do nearly all of its variant implementations. CPython
is managed by the non-profit Python Software Foundation.
The language's core philosophy is summarized in the document The Zen of Python
(PEP 20), which includes aphorisms such as:

 Beautiful is better than ugly

 Explicit is better than implicit

 Simple is better than complex


Page|7

Rather than having all of its functionality built into its core, Python was designed to
be highly extensible. This compact modularity has made it particularly popular as a
means of adding programmable interfaces to existing applications.

Downloading Python
If we don’t already have a copy of Python installed on our computer, we will need to
open up our Internet browser and go to the Python download page
(http://www.python.org/download/).

Now that we are on the download page, select which of the software builds we
would like to download. For the purposes of this article we will use the most up to
date version available (Python 3.6.3).
Page|8

Once we have clicked on that, we will be taken to a page with a description of all the
new updates and features of 3.4.1, however, we can always read that while the
download is in process. Scroll to the bottom of the page till we find the “Download”
section and click on the link that says “download page.”
Now we will scroll all the way to the bottom of the page and find the “Windows
x86 MSI installer.” If we want to download the 86-64 bit MSI, feel free to do so.
We believe that even if we have a 64-bit operating system installed on our
computer, the 86-bit MSI is preferable. We say this because it will still run well
and sometimes, with the 64-bit architectures, some of the compiled binaries and
Python libraries don’t work well.

Installing Python
Once we have downloaded the Python MSI, simply navigate to the download
location on our computer, double clicking the file and pressing Run when the
dialog box pops up.
If we are the only person who uses our computer, simply leave the “Install for all users”
option selected. If we have multiple accounts on our PC and don’t want to install it
across all accounts select the “Install just for me” option then press “Next.”
Scroll down in the window and find the “Add Python.exe to Path” and click on the
small red “x.” Choose the “Will be installed on local hard drive” option then press
“Next.” Now that we have completed the installation process, click on “Finish.
P a g e |9

Basic Syntax of Python


Computers are the machines that can interpret our instructions only if we type them in
the exact format that the computer expects. This expected format- the spelling,
formatting and grammar- is called syntax.
Programming elements :-

Identifiers
 Variables
 Keywords
 Functions
 Classes
 Modules
 Packages
 Keywords
Indents
Comments

Steps for fetching all Keywords :-


1. Open python shell
2. Write the command “import keyword” then press enter
3. Type command “keyword.kwlist” and press enter
List of all the keywords will appear on the screen.
P a g e | 10

Module – 2
Using Variables in Python
Data types and Variables

Data :- Raw facts and figures

Data Type :- Classification of data items

Data
types in
Python

Sequenc
Numeric Boolean e Dictionary

Complex
Integer Float Numbers String List Tuple

Variables :- Variable is the name given to an object, not to the memory location.
Variables are nothing but reserved memory locations to store values. This means that
when we create a variable we reserve some space in memory. Based on the data type
of a variable, the interpreter allocates memory and decides what can be stored in the
reserved memory.
P a g e | 11

Numeric Data Types


Integer :- In Python 3, there is effectively no limit to how long an integer value can be.
Of course, it is constrained by the amount of memory our system has, as are all things,
but beyond that an integer can be as long as we need it to be. Python interprets a
sequence of decimal digits without any prefix to be a decimal number.
The following strings can be prepended to an integer value to indicate a base other than
10:

Prefix Base
Interpretation

0b(zero + lowercase letter ‘b’) Binary 2


0B(zero + uppercase letter
‘B’)

0o(zero + lowercase letter ‘o’) Octal 8


0O(zero + uppercase letter
‘O’)

0x(zero + lowercase letter ‘x’) Hexadecimal 16


0X(zero + uppercase letter
‘X’)

Float :- The float type in Python designates a floating-point number. float values are
specified with a decimal point. Optionally, the character e or E followed by a positive or
negative integer may be appended to specify scientific notation.
Floating point numbers are represented internally as binary (base-2) fractions.
Most decimal fractions cannot be represented exactly as binary fractions.
P a g e | 12

Built-in functions for conversion of data types :-


Int() –> This function can convert another numeric type into an int.
Float() -> This function converts another numeric type into a float.
Complex() -> The complex() function converts another numeric type into a complex
number.

Sequence Data Type


String :-
Strings are sequences of character data. The string type in Python is called str.

String literals may be delimited using either single or double quotes. All the characters
between the opening delimiter and matching closing delimiter are part of the string.

For example:

>>> print(“I am a string”)

I am a string

>>>type(“I am a string”)

<class ‘str’>

Escape Sequences in Strings


Sometimes, we want Python to interpret a character or sequence of characters
within a string differently. This may occur in one of two ways:

We may want to suppress the special interpretation that certain characters


are usually given within a string.

We may want to apply special interpretation to characters in a string


which would normally be taken literally.

We can accomplish this using a backslash (\) character. A backslash character in a string
indicates that one or more characters that follow it should be treated specially.
P a g e | 13

The following is a table of escape sequences which cause Python to suppress the
usual special interpretation of a character in a string:

String Operators
P a g e | 14

String Operators

Methods for string processing

 format()  count()

 capitalize()  find()
isalpha(
 upper()  )
 islower(
 lower()  )
 isupper(
 title()  )

 index()  isdigit()

List :- List is an ordered sequence of items. It is one of the most used datatype in
Python and is very flexible. All the items in a list do not need to be of the same
type.Declaring a list is pretty straight forward. Items separated by commas are
enclosed within brackets [ ].

>>> a = [ 1 , 2.2 ,’python’ ]

We can use the slicing operator [ ] to extract an item or a range of items from a list.
Index starts from 0 in Python.
P a g e | 15

Lists are mutable, meaning, value of elements of a list can be altered.


For example :-

> a = [1,2,3]

> a[2]=4

> a

[1, 2, 4]

Tuple :- It is an ordered sequence of items same as list.The only difference is that


tuples are immutable. Tuples once created cannot be modified.

Tuples are used to write-protect data and are usually faster than list as it
cannot change dynamically.

It is defined within parentheses () where items are separated by commas.

>>> t = ( 5 , ‘program’ , 2+6j )

We can use the slicing operator [] to extract items but we cannot change its value.
P a g e | 16

Operators used in Sequence data type :-

 + Concatenation  [ : ] Range Slice

 * Repetition  in membership

not in
 [ ] Slice  membership

Built-in functions in Lists and Tuples :-


len( ) :- Calculates the length of the list and tuple

max( ) :- Finds the largest value from the list and tuple

min( ) :- Finds the smallest value from the list and tuple

Functioning for manipulating lists :-

 append( )  pop( )

reverse(
 insert( )  )

 remove( )  sort( )
P a g e | 17

Converting one Sequence type to Another :-

> t2 = (‘python’ , ‘java’ , ‘C++’ )

> list (t2)

[ ‘python’ , ‘java’ , ‘C++’ ]

> s1 = “Internshala”

> list (s1)

[ ‘I’ , ’n’ , ’t’ , ’e’ , ’r’ , ’n’ , ’s’ , ’h’ , ’a’ , ’l’ , ’a’ ]

>>> tuple(s1)

( ‘I’ , ’n’ , ’t’ , ’e’ , ’r’ , ’n’ , ’s’ , ’h’ , ’a’ , ’l’ , ’a’ )

Dictionary Data Type


Dictionary is an unordered collection of key-value pairs.

It is generally used when we have a huge amount of data. Dictionaries are


optimized for retrieving data. We must know the key to retrieve the value.

In Python, dictionaries are defined within braces {} with each item being a pair in the
form key:value. Key and value can be of any type. Key is immutable. A key should not
be repeated, if repeated the last value will be retained

The get( ) function is used to retrieve data from dictionary.

Built-in functions in Dictionary :-


> mobiles = {“One Plus 5T”:[6:”Quad-core”],’Lava Z80’:[3:’Quad-core’]}

len( ) : finds the length of the
dictionary eg- len(mobiles)
P a g e | 18


max( ) : finds maximum value from the
dictionary eg- max(mobiles)

min( ) : finds minimum value from the
dictionary eg- min(mobiles)

del( ) : can be used to delete
objects syntax-del(keyword)
eg- del(OnePlus 5T)

pop( ) : This method can be used to delete
objects eg- mobiles.pop(“Lava Z80”)

clear( ): This method returns empty
object eg- mobiles.clear( )

Other Methods of Dictionary Objects :-



items( ) : Returns a list of tuples, with each tuple containing one key and
corresponding value

keys( ) : Returns a list of object comprising keys in the dictionary

values( ) : Returns a list of object comprising values in the dictionary
P a g e | 19

Module – 3

Basics of Programming in Python

Advantages of Scripting mode


Easily insert, update and delete statements
Code or functions from a script can be imported

Automate and schedule tasks

Operators in Python

Arithmetic Operators
P a g e | 20

Comparison Operators

Logical Operators
P a g e | 21

Using Loops
Programming languages provide various control structures that allow for more
complicated execution paths.
A loop statement allows us to execute a statement or group of statements multiple
times. The following diagram illustrates a loop statement –

Python programming language provides following types of loops to handle


looping requirements.

Loop Type Description


Repeats a statement or group of statements while a given
while loop
condition is TRUE. It tests the condition before executing the
loop body.
Executes a sequence of statements multiple times and
abbreviates
for loop
the code that manages the loop variable.
We can use one or more loop inside any another while, for or
nested loops
do..while loop.

Example :

For Loop:
> for mynum in [1, 2, 3, 4,
5]: print "Hello", mynum
Hello
1
Hello
2
Hello
3
Hello
4
Hello
P a g e | 22

5
While Loop:
> count = 0
> while (count < 4):
print 'The count is:',

count count = count 1


The count is: 0
The count is: 1
The count is: 2
The count is: 3
P a g e | 23

Using Functions

Functions are independent and reusable block of instructions. Function blocks


begin with the keyword def followed by the function name and parentheses ( ).
Any input parameters or arguments should be placed within these parentheses.
We can also define parameters inside these parentheses.
The first statement of a function can be an optional statement – the documentation
string of the function.
The code block within every function starts with a colon (:) and is indented. The
statement return [expression] exits a function, optionally passing back an expression to
the caller. A return statement with no arguments is the same as return None.
Syntax :
def functionname( parameters ):
"function_docstring"
function_suite
return [expression]

Example :
1. def printme( str ):
"This prints a passed string into this function"
print str
return
2. # Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now we can call printme function
printme("I'm first call to user defined
function!") printme("Again second call to the
same function")
P a g e | 24

Math Module :- The math module is a standard module in Python and is always
available. To use mathematical functions under this module, you have to import the
module using import math. It contains functions like :
P a g e | 25
P a g e | 26

Constructing Modules and Package

Module
attributes

_dict_ _file_ _doc_ _name_

Package :- One or more relevant modules can be put into one package. Itmust contain
a special
file _init_.py, which is a packaging list.
_init_.py serves two purposes :-
i. The python interpreter recognizes a folder as package if it contains this file
ii. It exposes specified resources from its module to be imported

Steps to create a package :-


1. Create a folder with some name
2. Create a subfolder with same name
3. Place different modules in the subfolder
4. Create _init_ file by opening the IDLE in the scripting mode and save an empty
file with file name ‘ init .py’
5. Create the setup file and it must be placed in the parent folder.This allows us to
install the package
P a g e | 27

Steps to install the package :-


1. Launch the command prompt
2. Change to the parent directory
3. Exeute the command pip.install to execute the directory using utility pip
4. The package is now available to use in the system and can be imported from any
script

Module – 4
Principles of Object – Oriented Programming
Overview of OOP
 Programming languaages are classified into various paradigms like
procedural, imperative and object – oriented.
Programming paradigms are a way to classify programming languages
based on their features.
 Python supports multiple paradigms like Imperative, Procedural, Object –
Oriented and Functional.
Problems Related to Procedure Oriented language

Procedure Oriented languages make the program difficult to maintain.

Procedure Oriented languages use a lot of global data items and this results in
increased memory overhead.

Procedural approach gives more importance to process and doesn’t consider
data of same importance.
 Movements of data across functions is unrestricted.
Essential features of OOPs
o Data Encapsulation
o Inheritance
o Overriding
o Polymorphism
P a g e | 28

Declaring Class and Creating Objects


Class :- Classes are blueprints of the objects. We can think of class as a general
+idea of a category of an object.
Syntax : classs { name of the class }:
data items
methods( )
o Whenever a method is created in python the argument ‘self’ is to be passed
as the first argument.
o init ( ) method is invoked everytime when a object is created in a class.
It is called a constructor. Its job is to initialize the objects of the class.
Ex: class person:
def init (self,a=’Ravi’, b=’Male’):
Instance self.name = a Attributes or
methods instance
or self.gender = b variables
methods
def ShowInfo(self):
print(‘Name : ’ , self.name)
print(‘Gender : ’ self.gender)

Getter and Setter Methods


Getters and setters are used in many object oriented programming languages to
ensure the principle of data encapsulation. They are known as mutator methods as
well. Data encapsulation is seen as the bundling of data with the methods that operate
on these data. These methods are of course the getter for retrieving the data and the
setter for changing the data. According to this principle, the attributes of a class are
made private to hide and protect them from other code.
P a g e | 29

Example:-

Property ( ) method is used to set property.


 Variables starting with single underscore ‘_’ are protected.
 Variables staring with double underscore ‘ ’ are private.
P a g e | 30

Module – 6

Developing a GUI with PyQT

GUI and Event Driven Programming


GUI :- Graphical user interface (GUI), a computer program that enables a person to
communicate with a computer through the use of symbols, visual metaphors, and
pointing devices. Best known for its implementation in Apple Inc.’s Macintosh and
Microsoft Corporation’s Windows operating system, the GUI has replaced the arcane
and difficult textual interfaces of earlier computing with a relatively intuitive system
that has made computer operation not only easier to learn but more pleasant and
natural. The GUI is now the standard computer interface, and its components have
themselves become unmistakable cultural artifacts.

Event driven Programming :- An event-driven program is one that largely responds to


user events or other similar input. The concept of event-driven programming is an
important one in application development and other kinds of programming, and has
spawned the emergence of event handlers and other resources.
The idea in event-driven programming is that the program is designed to react.It
reacts to specific kinds of input from users, whether it's a click on a command
button, a choice from a drop-down list, an entry into a text box, or other kinds of
user events.

PyQT :- PyQt is a GUI widgets toolkit. It is a Python interface for Qt, one of the most
powerful, and popular cross-platform GUI library. PyQt was developed by RiverBank
Computing Ltd. The latest version of PyQt can be downloaded from its official website.
PyQt is a blend of Python programming language and the Qt library. PyQT API is a
collection of more then 400 classes.
P a g e | 31

Malor classes in PyQT :-

QObject is at the top of the class hierarchy. It is the base class of all the Qt objects.

QApplication class manages the main settings and control flow.

QWidget is the base class for all user interface objects.


QDialogue and Qframe classes are derived from the QWidget class.

Using Common Widgets


P a g e | 32

Qt Designer
Qt Designer is the Qt tool for designing and building graphical user interfaces (GUIs)
with Qt
Widgets. You can compose and customize your windows or dialogs in a what-you-see-is
-what-
you-get (WYSIWYG) manner, and test them using different styles and resolutions.
Widgets and forms created with Qt Designer integrate seamlessly with programmed
code, using
Qt's signals and slots mechanism, so that you can easily assign behavior to graphical
elements.
All properties set in Qt Designer can be changed dynamically within the code.
Furthermore,
features like widget promotion and custom plugins allow you to use your own
components
with Qt Designer.
Qt Designer helps only in designing GUI file, then it needs to be converted into py file. By
using pyuic 5 utility xml file can be converted into .py file and is installed alongwith
PyQT5 package.

We use pyuic5-x myui.ui-o myui.py command to convert ui file to python file.For the
sake of simplicity, we place myuic.ui file in the same folder where pyuic5.exe file is
placed.

Reasons for choosing this Technology


Scope of Python

Science
o Bioinformatics
System Administration
o Unix
o Web logic
o Web sphere
Web Application Development
P a g e | 33

Uses of Python
System programming
Graphical User Interface Programming
Internet Scripting
Component Integration
Database Programming
Gaming, Images, XML , Robot and more

Who Uses Python Today?



Python is being applied in real revenue-generating products by real companies.

Google makes extensive use of Python in its web search system, and employs
Python’s creator.

Intel, Cisco, Hewlett-Packard, Seagate, Qualcomm, and IBM use Python for
hardware testing.

ESRI uses Python as an end-user customization tool for its popular GIS
mapping products.
 The YouTube video sharing service is largely written in Python.

Features of Python
The following primary factors cited by Python users seem to be these:

Python is object-oriented

Structure supports such concepts as polymorphism, operation
overloading, and multiple inheritance.
Indentation

Indentation is one of the greatest future in Python.
 It's free (open source)

Downloading and installing Python is free and easy

Source code is easily accessible
P a g e | 34

Testing

WHITE BOX TESTING (also known as Clear Box Testing, Open Box Testing, Glass Box Testing,
Transparent Box Testing, Code-Based Testing or Structural Testing) is a software testing method in
which the internal structure/design/implementation of the item being tested is known to the tester.
The tester chooses inputs to exercise paths through the code and determines the appropriate
outputs. Programming know-how and the implementation knowledge is essential. White box testing
is testing beyond the user interface and into the nitty-gritty of a system.
This method is named so because the software program, in the eyes of the tester, is like a
white/transparent box; inside which one clearly sees.

BLACK BOX TESTING, also known as Behavioral Testing, is a software testing method in which
the internal structure/design/implementation of the item being tested is not known to the tester.
These tests can be functional or non-functional, though usually functional.

This method is named so because the software program, in the eyes of the tester, is like a black
box; inside which one cannot see. This method attempts to find errors in the following categories:

 Incorrect or missing functions


 Interface errors
 Errors in data structures or external database access
 Behavior or performance errors
 Initialization and termination errors

Gantt chart

 Gantt charts are useful tools for planning and scheduling projects. Product managers use
Gantt charts in many different ways. For example, you can create a Gantt chart to manage
your strategic planning process, product release, or user research project.
P a g e | 35

Project legacy
 Using Variable in Python
 Basic Programming in Python and Principle of OOPS
 Developing GUI Using PyQt
 Application Of Python in Various Discipline like Data
Science,Advance Photo Processing and Machine Learning

CODING
from tkinter import *
import tkinter.messagebox as tm
grades_of_all_courses = list()
credits_of_all_courses = list()
CGPA = 0
#f = tkFont.Font(family='comic sans MS',size=16)
#def Continue():
#f = tkFont.Font(family='comic sans MS', size=16)
window_1 = Tk()
lbf1 = Label(window_1,bg='sky blue',fg='white',font=('comic sans
MS',14),text='WELCOME TO THE CGPA CALCULATOR.\n'
'PLEASE DO NOT LEAVE ALL THE FIELDS
EMPTY.'
'IF YOU DO NOT HAVE 10 COURSES LEAVE
THE REMAINING ENTRIES AND CLICK ON SUBMIT.\n'
'FIRST SUMBIT THE VALUES AND THEN
CLICK ON CALCULATE CGPA.\n'
'YOUR CGPA WILL BE SHOWN IN A NEW
WINDOW')
lbf1.pack(side='top')
window_1.state('zoomed')
window_1.configure(background='sky blue')
window_1.title('C.G.P.A. CALCULATOR')
label_1 = Label(window_1, bg='sky blue', fg='white', text='Enter the
grade in course '+str(1)).place(x=200,y=120)
course_1 = StringVar()
entry_1 = Entry(window_1, textvariable=course_1).place(x=400,y=120)
labelc_1 = Label(window_1,bg='sky blue', fg='white', text='Enter the
credit hours in course '+str(1)).place(x=200,y=150)
P a g e | 36

ch_1 = StringVar()
entryc_1 = Entry(window_1, textvariable=ch_1).place(x=400,y=150)

label_2 = Label(window_1, bg='sky blue', fg='white',text='Enter the grade


in course '+str(2)).place(x=200,y=180)

course_2 = StringVar()
entry_2 = Entry(window_1, textvariable=course_2).place(x=400,y=180)
labelc_2 = Label(window_1,bg='sky blue', fg='white', text='Enter the
credit hours in course '+str(2)).place(x=200,y=210)
ch_2 = StringVar()
entryc_2 = Entry(window_1, textvariable=ch_2).place(x=400,y=210)

label_3 = Label(window_1,bg='sky blue', fg='white', text='Enter the grade


in course '+str(3)).place(x=200,y=240)
course_3 = StringVar()
entry_3 = Entry(window_1, textvariable=course_3).place(x=400,y=240)
labelc_3 = Label(window_1,bg='sky blue', fg='white', text='Enter the
credit hours in course '+str(3)).place(x=200,y=270)
ch_3 = StringVar()
entryc_3 = Entry(window_1, textvariable=ch_3).place(x=400,y=270)

label_4 = Label(window_1,bg='sky blue', fg='white', text='Enter the grade


in course '+str(4)).place(x=200,y=300)
course_4 = StringVar()
entry_4 = Entry(window_1, textvariable=course_4).place(x=400,y=300)
labelc_4 = Label(window_1,bg='sky blue', fg='white', text='Enter the
credit hours in course '+str(4)).place(x=200,y=330)
ch_4 = StringVar()
entryc_4 = Entry(window_1, textvariable=ch_4).place(x=400,y=330)

label_5 = Label(window_1,bg='sky blue', fg='white', text='Enter the grade


in course '+str(5)).place(x=200,y=360)
course_5 = StringVar()
entry_5 = Entry(window_1, textvariable=course_5).place(x=400,y=360)
P a g e | 37

labelc_5 = Label(window_1,bg='sky blue', fg='white', text='Enter the


credit hours in course '+str(5)).place(x=200,y=390)
ch_5 = StringVar()
entryc_5 = Entry(window_1, textvariable=ch_5).place(x=400,y=390)

label_6 = Label(window_1,bg='sky blue', fg='white', text='Enter the grade


in course '+str(6)).place(x=200,y=420)
course_6 = StringVar()

entry_6 = Entry(window_1, textvariable=course_6).place(x=400,y=420)


labelc_6 = Label(window_1,bg='sky blue', fg='white', text='Enter the
credit hours in course '+str(6)).place(x=200,y=450)
ch_6 = StringVar()
entryc_6 = Entry(window_1, textvariable=ch_6).place(x=400,y=450)

label_7 = Label(window_1,bg='sky blue', fg='white', text='Enter the grade


in course '+str(7)).place(x=200,y=480)
course_7 = StringVar()
entry_7 = Entry(window_1, textvariable=course_7).place(x=400,y=480)
labelc_7 = Label(window_1,bg='sky blue', fg='white', text='Enter the
credit hours in course '+str(7)).place(x=200,y=510)
ch_7 = StringVar()
entryc_7 = Entry(window_1, textvariable=ch_7).place(x=400,y=510)

label_8 = Label(window_1,bg='sky blue', fg='white', text='Enter the grade


in course '+str(8)).place(x=200,y=540)
course_8 = StringVar()
entry_8 = Entry(window_1, textvariable=course_8).place(x=400,y=540)
labelc_8 = Label(window_1,bg='sky blue', fg='white', text='Enter the
credit hours in course '+str(8)).place(x=200,y=570)
ch_8 = StringVar()
entryc_8 = Entry(window_1, textvariable=ch_8).place(x=400,y=570)

label_9 = Label(window_1,bg='sky blue', fg='white', text='Enter the grade


in course '+str(9)).place(x=200,y=600)
course_9 = StringVar()
entry_9 = Entry(window_1, textvariable=course_9).place(x=400,y=600)
P a g e | 38

labelc_9 = Label(window_1,bg='sky blue', fg='white', text='Enter the


credit hours in course '+str(9)).place(x=200,y=630)
ch_9 = StringVar()
entryc_9 = Entry(window_1, textvariable=ch_9).place(x=400,y=630)

label_10 = Label(window_1,bg='sky blue', fg='white', text='Enter the


grade in course '+str(10)).place(x=200,y=660)
course_10 = StringVar()
entry_10 = Entry(window_1, textvariable=course_10).place(x=400,y=660)

labelc_10 = Label(window_1,bg='sky blue', fg='white', text='Enter the


credit hours in course '+str(10)).place(x=200,y=690)

ch_10 = StringVar()
entryc_10 = Entry(window_1, textvariable=ch_10).place(x=400,y=690)

def onclick():
x1 = course_1.get()
xc1 = ch_1.get()
credits_of_all_courses.append(xc1)

grades_of_all_courses.append(x1)
x2 = course_2.get()
xc2 = ch_2.get()
credits_of_all_courses.append(xc2)
grades_of_all_courses.append(x2)
x3 = course_3.get()
xc3 = ch_3.get()
credits_of_all_courses.append(xc3)
grades_of_all_courses.append(x3)
x4 = course_4.get()
xc4 = ch_4.get()
credits_of_all_courses.append(xc4)
grades_of_all_courses.append(x4)
x5 = course_5.get()
xc5 = ch_5.get()
credits_of_all_courses.append(xc5)
P a g e | 39
x6 = course_6.get()
xc6 = ch_6.get()
credits_of_all_courses.append(xc6)
grades_of_all_courses.append(x6)
x7 = course_7.get()
xc7 = ch_7.get()
credits_of_all_courses.append(xc7)
grades_of_all_courses.append(x7)
x8 = course_8.get()
xc8 = ch_8.get()
credits_of_all_courses.append(xc8)
grades_of_all_courses.append(x8)
x9 = course_9.get()
xc9 = ch_9.get()
credits_of_all_courses.append(xc9)
grades_of_all_courses.append(x9)
x10 = course_10.get()
xc10 = ch_10.get()
credits_of_all_courses.append(xc10)
grades_of_all_courses.append(x10)
#print(grades_of_all_courses)
#print(credits_of_all_courses)
n1 = len(grades_of_all_courses)
cc1 = 0
i=0
while i < n1:
if cc1 > 0:
i=i-1

n1 = n1 - 1
if grades_of_all_courses[i] == '':
grades_of_all_courses.pop(i)
cc1 += 1
i += 1
n2 = len(credits_of_all_courses)
cc2 = 0
i=0
while i < n2:
if cc2 > 0:
i=i-1
P a g e | 40

n2 = n2 - 1
if credits_of_all_courses[i] == '':
credits_of_all_courses.pop(i)
cc2 += 1
i += 1
for i in range(len(credits_of_all_courses)):
credits_of_all_courses[i] = int(credits_of_all_courses[i])
button_1 = Button(window_1,bg='sky blue', fg='white',font=('comic sans
MS',16), text='submit',command=onclick).place(x=640,y=330)
def calculate():
grades_scale = {'O': 10, 'A+': 9, 'A': 8, 'B+': 7, 'B': 6, 'C+': 5, 'C': 4}
sum_of_grades = 0

for i in range(len(grades_of_all_courses)):
if grades_of_all_courses[i] in grades_scale:
grades_of_all_courses[i] =
grades_scale[grades_of_all_courses[i]]
for i in range(len(grades_of_all_courses)):
sum_of_grades +=
grades_of_all_courses[i]*credits_of_all_courses[i]
total_credit_hours = 0
for i in range(len(credits_of_all_courses)):
total_credit_hours += credits_of_all_courses[i]
CGPA = sum_of_grades/total_credit_hours
window_2 = Tk()
window_2.state('zoomed')
window_2.configure(bg='yellow')
l = Label(window_2, bg='yellow', fg='black', font=('comic sans MS', 36),
text='YOUR C.G.P.A IS ' + str(CGPA)).place(x=500,y=350)
window_2.mainloop()

button_2 = Button(window_1,bg='sky blue', fg='white',font=('comic sans


MS',16), text='Calculate CGPA', command=calculate).place(x=600,y=430)
window_1.mainloop()
P a g e | 41

Conclusion
I believe the trial has shown conclusively that it is both possible and desirable to use
Python as the principal teaching language:
 It is Free (as in both cost and source code).
 It is trivial to install on a Windows PC allowing students to take their interest
further. For many the hurdle of installing a Pascal or C compiler on a Windows
machine is either too expensive or too complicated;
 It is a flexible tool that allows both the teaching of traditional procedural
programming and modern OOP; It can be used to teach a large number of
transferable skills;

 It appears to be quicker to learn and, in combination with its many libraries,


this offers the possibility of more rapid student development allowing the
course to be made more challenging and varied;
 Most importantly, its clean syntax offers increased understanding and
enjoyment for students.

Bibliography
www.telcocrats.com

You might also like