Professional Documents
Culture Documents
At
STEP
SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR THE AWARD
OF THE DEGREE OF
BACHELOR OF TECHNOLOGY
SUBMITTED BY:
Paramvir singh
URN: -2004635 CRN:-2015100
1
CANDIDATE'S DECLARATION
I Nitesh Kumar hereby declare that I have undertaken one month training GURU
AUGUST 2022 in partial fulfillment of requirements for the award of degree of B. Tech
COLLEGE, LUDHIANA. The work which is being presented in the training report submitted to
the Department of Computer Science and Engineering at GURU NANAK DEV ENGINEERING
2
3
ACKNOWLEDGEMENT
It is my proud privilege and duty to acknowledge the kind of help and guidance received in
preparation of this report.First and for most,I wish to record our since regratitude to “STEP
GNDEC” for their constant support and encouragement in preparation of this report .Their
contributions and technical support in preparing this report are greatly acknowledged .Last but not
the least , we wish to thank our parents for constantly encouraging us to learn .Their personal
With regards
Param Rai
4
ABSTRACT
It give us immense pleasure to find an opportunity to express our deep gratitude to Dr. Sehijpal
Singh (PRINCIPAL), Dr. Parminder Singh (HOD) of Computer Science & Engineering, Guru Nanak
Dev Engineering College, Ludhiana for enthusiasticenc enragement and useful critiques of this
project. We hereby acknowledge our sincere thanks for valuable guidance. We would also like to
thank to the technician of the Step Gndec for help in of feringus the resources during the project. We
are greatly indebted to all those writers and organization whose books, articles and reports we have
used as reference in preparing the project file. We thank all our branch teachers and faculties of
ii
5
LIST OFFIGURES
LIST OFTABLES
6
CONTENTS
Topic Page no.
Candidate's Declaration i
Acknowledgement ii
1.1 Python 1
Chapter-2 Training Work Undertaken 4-24
2.1 Functions 4
2.2 Classes 5
2.3 Inheritance 11
2.4 Constructor 17
2.5 Destructor 20
3.1 Introduction 25
4.1 conclusion 30
References 31
iv
7
CHAPTER-1 INTRODUCTION
1.1 PYTHON
Python is an easy to learn, powerful programming language. It has efficient high-level data structures
and a simple but effective approach to object-oriented programming. Python’s elegant syntax and
dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid
application development in many areas on most platforms. The Python interpreter and the extensive
standard library are freely available in source or binary form for all major platforms from the Python web
site, https://www.python.org/,and may be freely distributed. The same site also contains distributions of
and pointers to many free third party Python modules, programs and tools, and additional documentation.
he Python interpreter is easily extended with
newfunctionsanddatatypesimplementedinCorC++(orotherlanguagescallablefromC).Python is also
suitable as an extension language for customizable applications.
This tutorial introduces the reader informally to the basic concepts and features of the Python language
and system. It helps to have a Python interpreter handy for hands-on experience, but all examples are
self-contained, so the tutorial can be read off-line aswell.
For a description of standard objects and modules, see The Python Standard Library. The
Python Language gives a more formal definition of the language. To write extensions in C or C++, read
Extending and Embedding the Python Interpreter and Python/C API Reference Manual.There are also
several books covering Python in depth.
This tutorial does not attempt to be comprehensive and cover every single feature, or even every
commonly used feature. Instead, it introduces many of Python’s most noteworthy features, and will give
you a good idea of the language’s flavor and style. After reading it, you will be able to read and write
Python modules and programs, and you will be ready to learn more about the various Python library
8
Python
Pythonisextremelyeasytolearn.ItssyntaxissupersimpleandthelearningcurveofPythonisverysmooth.It is
extremely easy to learn and code in Python and the indentation used instead of curly braces in Python
makesitveryeasytoreadPythoncode.Perhaps,becauseofthisalotofschoolsanduniversities,andcolleges are
teaching Python to their students who are beginning their journey withcoding.
Python is an open-source programming language and one can download it for free from Python’s official
website.ThecommunityofPythonusersisconstantlycontributingtothecodeofPythoninordertoimprove it.
3. High-LevelLanguage
4. Extensible andEmbeddable
Python is an Embeddable language. We can write some Python code into C or C++ language and also
we can compile that code in C/C++ language. Python is also extensible. It means that we can extend
our Python code in various other languages like C++, etc. too.
2.1 Functions
A function is a block of organized, reusable code that is used to perform a single, related action.
Functions provide better modularity for your application and a high degree of code reusing.
As you already know, Python gives you many built-in functions like print(), etc. but you can also
create your own functions. These functions are called user-defined functions.
9
Defining a Function
You can define functions to provide the required functionality. Here are simple rules to define a
function in Python.
• 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. You can
also define parameters inside theseparentheses.
• The first statement of a function can be an optional statement - the documentation string
of the function or docstring.
• The code block within every function starts with a colon (:) and isindented.
• 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 :-
function_suite
By default, parameters have a positional behavior and you need to inform them in the same order that
they were defined.
Example:-
The following function takes a string as input parameter and prints it on standard screen.
Calling a Function
Defining a function only gives it a name, specifies the parameters that are to be included in the function
and structures the blocks of code.
Once the basic structure of a function is finalized, you can execute it by calling it from another function
or directly from the Python prompt. Following is the example to call printme() function −
Live Demo
10
Figure-2.1 Functions
2.2 Classes
Classes provide a means of bundling data and functionality together. Creating a new class createsa
new type of object, allowing new instances of that type to be made. Each class instance can have
attributes attached to it for maintaining its state. Class instances can also have methods (defined by its
class) for modifying itsstate.
Compared with other programming languages, Python’s class mechanism adds classes with a
minimum of new syntax and semantics. It is a mixture of the class mechanisms found in C++ and
Modula-3. Python classes provide all the standard features of Object Oriented Programming: the
classinheritancemechanismallowsmultiplebaseclasses,aderivedclasscanoverrideanymethods of its
base class or classes, and a method can call the method of a base class with the same name. Objects
can contain arbitrary amounts and kinds of data. As is true for modules, classes partake of
thedynamicnatureofPython:theyarecreatedatruntime,andcanbemodifiedfurtheraftercreation.
1
0
In C++ terminology, normally class members (including the data members) are public (except see
below Private Variables), and all member functions are virtual. As in Modula-3, there are no
shorthands for referencing the object’s members from its methods: the method function is declared
with an explicit first argument representing the object, which is provided implicitly by the call. As
inSmalltalk,classesthemselvesareobjects.Thisprovidessemanticsforimportingandrenaming.
UnlikeC++andModula-3,built-intypescanbeusedasbaseclassesforextensionbytheuser.Also,
likeinC++,mostbuilt-inoperatorswithspecialsyntax(arithmeticoperators,subscriptingetc.)can be
redefined for classinstances.
(Lacking universally accepted terminology to talk about classes, I will make occasional use of
SmalltalkandC++terms.IwoulduseModula-3terms,sinceitsobject-orientedsemanticsarecloser to
those of Python than C++, but I expect that few readers have heard ofit.)n
Defining a class
class <ClassName>:
<statement1>
<statement2> .
.
<statementN>
As per the syntax above, a class is defined using the class keyword followed by the class name and
:operatoraftertheclassname,whichallowsyoutocontinueinthenextindentedlinetodefineclass members.
The followings are classmembers.
Class Attributes
Class attributes are the variables defined directly in the class that are shared by all objects of the class.
Class attributes can be accessed using the class name as well as using the objects.
Above, the schoolName is a class attribute defined inside a class. The value of the schoolName
will remain the same for all the objects unless modified explicitly.
1
1
across all instances. However, changing class attribute value using instance will not reflect to other
instances or class.
2.3 Inheritance
One of the core concepts in object-oriented programming (OOP) languages is inheritance. It is a
mechanismthatallowsyoutocreateahierarchyofclassesthatshareasetofpropertiesandmethods by
deriving a class from another class. Inheritance is the capability of one class to derive or inherit the
properties from anotherclass.
Types of inheritance
Types of Inheritance depend upon the number of child and parent classes involved. There are four
types of inheritance inPython:
1. SingleInheritance:
Single inheritance enables a derived class to inherit properties from a single parent class, thus enabling
code reusability and the addition of new features to existing code.
1
2
Figure-2.2 Single Inheritance
Example :-
# Driver's code
object = Child()
object.func1()
object.func2()
Output:-
Father : RAM
Mother : SITA
2. MultipleInheritance:
When a class can be derived from more than one base class this type of inheritance is called multiple
inheritances. In multiple inheritances, all the features of the base classes are inherited into the derived
class.
1
3
Figure-2.3 Multiple Inheritance
Example:
# multiple inheritance
class Father:
fathername = "" def
father(self): print(self.fathername)
# Derived class
class Son(Mother, Father):
def parents(self):
print("Father :", self.fathername)
print("Mother :", self.mothername)
Output:-
Lal mani
Grandfather name : Lal mani
Father name : Rampal
Son name : Prince
3. HierarchicalInheritance:
When more than one derived class are created from a single base this type of inheritance is called
hierarchical inheritance. In this program, we have a parent (base) class and two child (derived)
classes.
Example:
1
5
class
Child2(Parent): def
func3(self):
print("This function is in child 2.")
# Driver's code
object1 = Child1()
object2 = Child2()
object1.func1()
object1.func2()
object2.func1()
object2.func3()
Output:
This function is in parent class. This
function is in child 1.
This function is in parent class.
This function is in child 2.
4. Hybrid Inheritance:
Example:
1
6
class School:
def func1(self):
print("This function is in school.")
class
Student1(School): def
func2(self):
print("This function is in student 1. ")
class
Student2(School): def
func3(self):
print("This function is in student 2.")
Output:
This function is in school. This function
is in student 1.
2.4 Constructor
Constructors are generally used for instantiating an object. The task of constructors is to
initialize(assign values) to the data members of the class when an object of the class is created. In
Python theinit() method is called the constructor and is always called when an object is created. Syntax
of constructor declaration :
definit(self):
# body of the constructor
Types of constructors :
1
7
• default constructor: The default constructor is a simple constructor which doesn’t
accept any arguments. Its definition has only one argument which is a reference to the
instance beingconstructed.
• parameterized constructor: constructor with parameters is known as
parameterized constructor. The parameterized constructor takes its first argument
as a reference to the instance being constructed known as self and the rest of the
arguments are provided by theprogrammer.
classGeekforGeeks:
#defaultconstructor definit(self):
self.geek="GeekforGeeks"
#amethodforprintingdatamembers def
print_Geek(self):
print(self.geek)
#creatingobjectoftheclassobj
=GeekforGeeks()
#callingtheinstancemethodusingtheobjectobj obj.print_Geek()
Output:-
GeekforGeeks
Example of the parameterized constructor :
classAddition:
first=0 second
=0 answer=0
#parameterizedconstructor
definit(self,f,s): self.first=fself.secon
d=s def
display(self): print("Firstnumber="+str(self.first))
print("Secondnumber="+str(self.second))
print("Additionoftwonumbers="+str(self.answer)) def
calculate(self):
self.answer=self.first+self.second
#creatingobjectoftheclass
#thiswillinvokeparameterizedconstructor
obj=Addition(1000,2000) #performAddition
obj.calculate()
#displayresultobj.display()
1
8
Output :
First number = 1000
Second number = 2000
Addition of two numbers = 3000
2.5 Destructor
Destructors are called when an object gets destroyed.In python,destructors are not needed as
Much as in c++ because Python has garbage collector that handles memory management auto
Matically.
Thedel() method is a known as destructor method in python.It is called when all refer- Ences
to the object have been deleted i.e whwn an object is garbage collected.
defdel(self):
# body of destructor
Example:-
1
9
#Pythonprogramtoillustratedestructor class
Employee:
# Initializing definit(self):
print('Employeecreated.')
Output:-
Employee created.
Destructor called, Employee deleted.
Importing tkinter is same as importing any other module in the Python code. Note that the name of
the module in Python 2.x is ‘Tkinter’ and in Python 3.x it is ‘tkinter’.
import tkinter
Tkinter widgets
tkinter provides various controls, such as buttons, labels and text boxes used in a GUI application.
.
Checkbutton:- The Checkbutton widget is used to display a number of options as checkboxes.
The user can select multiple options at a time.
Entry:- The Entry widget is used to display a single-line text field for accepting values from a
user.
Frame:- The Frame widget is used as a container widget to organize other widgets.
Label:- The Label widget is used to provide a single-line caption for other widgets. It can also
contain images.
Listbox:- The Listbox widget is used to provide a list of options to a user.
Menubutton:- The Menubutton widget is used to display menus in your application.
Menu:- The Menu widget is used to provide various commands to a user. These commands are
contained inside menubutton.
Message:- The Message widget is used to display multiline text fields for accepting values from
a user.
Radiobutton:- The Radiobutton widget is used to display a number of options as radio buttons.
The user can select only one option at a time.
Scale:- The Scale widget is used to provide a slider widget
Scrollbar:- The Scrollbar widget is used to add scrolling capability to various widgets, such as
list boxes.
Text:- The Text widget is used to display text in multiple lines.
Toplevel:- The Toplevel widget is used to provide a separate window container
Spinbox:- The Spinbox widget is a variant of the standard Tkinter Entry widget, which can be
used to select from a fixed number of values.
PanedWindow:- A PanedWindow is a container widget that may contain any number of panes,
arranged horizontally or vertically.
LabelFrame:- A labelframe is a simple container widget. Its primary purpose is to act as a spa-
cer or container for complex window layouts. tkMessageBox:- This module is used to display
message boxes in your applications
2
1
Figure-2.6 Tkinter widgets
3.1 INTRODUCTION
Python has become one of the most popular languages. So getting only the theoretical knowledge will
be of no use unless and until you don’t work on some real-time projects. Working on such projects will
test your Python knowledge and you will get some hands-on experience. Moreover, working on such
projects will help you improve your knowledge.
ThisarticleaimedatcoveringPythonprojectideasfrombeginnersleveltoadvancelevelundereach domain
such as projects on GUI, projects on web development or projects involving the realtime face, vehicle,
gun, sentiment detection, even the projects involving some automation or voice assistant and many
more exciting projects are alsoincluded.
2
2
Figure 3.1 Python Project
2
3
3.3 PythonCode
import requests
import smtplib
import time
frommail = 'sendermail'
passwd = 'emailidpwd'
tomail = 'recievermail'
root = Tk()
root.geometry("600x300")
root.resizable(height=False, width=False)
2
4
Email = "yourmail"
# Product Price
def checkprice():
try:
global product_link
global price
product_link = link.get()
page =requests.get(product_link)
product_name = soup.find(class_='B_NuCI').get_text()
print(product_name ,price)
product_window = Toplevel()
product_window.geometry("200x200")
details_name.grid(row=0,column=0)
2
5
details_price.grid(row=0,column=1)
link.delete(0,END)
except:
def notify():
global budget
budget=int(budget.get())
server.ehlo()
server.starttls()
server.ehlo()
server.login(frommail, passwd)
2
6
msg = 'Subject: {}\n\n{}'.format(subject, body)
if(42000<=budget):
else:
server.quit()
#GUI
link.insert(0,"Link")
budget.insert(0,"Budget")
check_price.grid(row=2, column=0,padx=(70,5))
2
7
submit.grid(row=3, column=1,padx=(10,40))
root.mainloop()
2
8
2
9
3.4 Python Code to GUImode
Here is the output screenshot for the above code. Here you can notice that a Listbox is appearing
with a scrollbar. Entry box I placed right below it followed by two buttons.
2
10
Figure 3.3 Output
2
11
4.1 CONCLUSION
Congratulations! We have successfully completed the beginner’s course on Python. You should
now be comfortable enough to write intermediate level programs in it. However, I would suggest
a few benefits from this course.
Note that these suggestions are from the amount of knowledge I have. There might be a lot more
options to explore. You should proceed according to your interests.
We will focus on a few important aspects only. I hope you can use it in a better way after reading
this.
Usually, after learning a language, I find most students moving into another programming language.
This is usually because one prefers to showcase their technical skills. Mostly they would prefer saying
that they know 20+ languages. My advice: Stick to one language and excel in it.
This can be of immense benefit. And basically in python, the future benefits can be as:
1. Python is easily readable and maintainable across a wide chain of developers. It is so because
ithaskickedonestephighertotheprogrammingparadigm.Thecodewhichiswrittenresembles plain
English and can be understood even by beginner programmers. It also helps to update the code
easily from time to time and invest less effort in doingso.
2. Python supports both function-oriented and structure-orientedprogramming.
3. Ithasfeaturesofdynamicmemorymanagementwhichcanmakeuseofcomputationalresources
efficiently.
4. It is also compatible with all popular operating systems and platforms. Hence this language can
be universally accepted by allprogrammers.
5. Python supports a large built-in library from which we can extract any feature to implement in
the form of packages. Thus it enables us to implement a feature without writing excesscode.
4.2 FUTURESCOPE
But first, let’s look at the roles and responsibilities of a Python Programmer.
Let’s talk about some of the main duties and jobs performed by professionals in this industry.
2
12
• Evaluating and ranking client featurerequests
• Work together with front-endprogrammers.
• Upgrading the functionality of currentdatabases.
• Create internet traffic monitoringsoftware
4.2.2 SoftwareEngineer
A DevOps engineer adds methods, tools, and approaches to balance demands across the software
development process, from coding and installation to maintenance and upgrades. The
compensation of DevOps Engineers reflects the career of such individuals in this very promising
field, which offers development.
4.2.3 ProgramEngineer
A software engineer is another term for a coder. These experts create, develop, test, and review
computer software using software engineering concepts. Software experts have been in high
demand in recent years. Additionally, according to data from the U.S. Bureau of Labor Statistics,
jobs in software development are expected to grow by 22% between 2020 and 2030.
India, one of the world’s fastest-growing economies, is embracing big data, machine learning, and
computer science rapidly. According to a recent survey, India’s analytical business is expanding at an
astounding pace of 35.1%. In India, Python is a popular technology due to its adaptability.
Additionally, because of its straightforward syntax, it has gained significant use in the analytics
sector. As a result, python coders may find career possibilities across numerous industrial sectors,
from healthcare to retail. Python’s acceptance will grow more widely in India as AI and machine
learning progress there.
2
13
REFERENCES
https://www.gyansetu.in/blogs/future-scope-of-python-in-india//-
23/11/22https://www.geeksforgeeks.org/
20/11/22
https://www.javatpoint.com18/11/22
https://www.tutorialspoint.com/python/python_gui_programming.
htm
16/11/22
https://www.freecodecamp.org/news/python-code-
examplessamplescript-coding-tutorial-for-beginners/
.
3 0