INDUSTRIAL REPORT On Python
INDUSTRIAL REPORT On Python
ON
“PYTHON”
BACHELOR OF TECHNOLOGY
in
COMPUTER SCIENCE ENGINEERING
at
ARKA JAIN UNIVERSITY, Jharkhand
Submitted By
PREM KUMAR SINGH
AJU/190266
Under the Guidance of
SUNIL KUMAR
(Trainer , ThinkNEXT TECHNOLOGIES Private Limited)
2. The details of training and experience contain in this report describe my involvement
as a trainee in the field of Computer Science Engineering.
3. All the information contains in this report is certain and correct to the knowledge.
Signature:
iii
CERTIFICATE
This is to certify that the Industrial Training Report titled "PYTHON" in partial fulfillment of
the requirement for the award of the Degree of Bachelor of Engineering in Computer Science
Engineering, submitted to ARKA JAIN University, Jharkhand, is an authentic record of
bonafide industrial training work carried out by Mr. Prem Kumar Singh and submitted under
my supervision/guidance.
iv
ACKNOWLEDGEMENT
I would like to express my utmost gratitude to the AJU for providing an opportunity to pursue
the engineering training as partial fulfillment of the requirement for the degree of Bachelor of
Technology in Computer Science Engineering. The internship opportunity I had with THINK
NEXT was a great chance for learning and professional development. Therefore, I consider
myself as a very lucky individual as I was provided with an opportunity to be a part of it. I am
also grateful for having a chance to meet so many wonderful people and professionals who led
me through this internship period.
Bearing in mind previous I am using this opportunity to express my deepest gratitude and special
thanks to the Mr. RAMANDEEP KAUR, H.R, THINKNEXT TECHNOLOGIES
(CHANDIGARH) who in spite of being extraordinarily busy with his duties, took time out to
hear, guide and keep me on the correct path and allowing me to carry out my project at their
esteemed organization and extending during the training.
I express my deepest thanks to all staffs and employees of THINKNEXT TECHNOLOGIES for
taking part in useful decision & giving necessary advice and guidance and arranged all facilities
to make life easier. I choose this moment to acknowledge their contribution gratefully. I perceive
as this opportunity as a big milestone in my career development. I will strive to use gained skills
and knowledge in the best possible way, and I will continue to work on their improvement, in
order to attain desired career objectives. Hope to continue cooperation with all of you in the
future.
v
ABSTRACT
This report discusses the training program at THINK NEXT TECHNOLOGIES PRIVATE
LIMITATED company. It states the concepts of python programming.
It shows the brief background about the place of training. It mentions some facts about the
department that was responsible for the training program. The report describe about the history,
characteristics, overview and concept of python programming.
vi
TABLE OF CONTENTS
CHAPTER-3 DATATYPES
CHAPTER-4 OPERATOR
4.1Arithmetic Operator 08
4.2 Comparision Operator 08
4.3Assignment Operator 09
4.4Bitwise Operator 10
4.5 Special Operator 10
4.6 Membership Operator 10
4.7 Identity Operator 11
CHAPTER-6 FUNCTION
6.1Types of Function 18
vii
6.2Defining a Function 19
6.3Calling a Function 19
6.4 Arguments in Function 19-20
CHAPTER-7 OOPS
7.1 Class 21
7.2 Object 21
7.3 Inheritance 22
7.4 Polymorphism 22
7.5 Encapsulation 22
CHAPTER-8.CONSTRUCTORS 23
8.1 Types of Constructor 24
PROJECT 26-27
CONCLUSION 28
BIBLIOGRAPHY 29
viii
Chapter-1
Introduction
1.1 INTRODUCTION OF TRAINING
The purpose of industrial training is to provide exposure for the student on practical
engineering fields. Through this exposure, students will have better understandings of
engineering practical in general and sense of frequencies and possible problems. This training
is part of learning process. So the exposure that uplift the knowledge and experience of a
student need to be properly documented in the form of a report. Through this report, the
experience gained can be delivered to their peers. A properly prepared report can facilitate the
presentation of the practical experience in an orderly, precise and interesting manner.
I have chosen python as an training because it will help in many ways. I have chosen my
language course in python and by having little bit knowledge in this subject which help me to
make carrier in this field. During the learning of python the concepts of other languages are
also get cleared as well as, i got new ideas on projects too.
Think NEXT offers various 6 Months/3 Months/ 6 Weeks/45 days/Summer Industrial Training
programs for Bachelor in technology and Engineering students, MCA, BCA, Polytechnic
Diploma, Master degree of science (IT), Bachelor degree of Science (IT), MBA, BBA, B. Com
students and job-seekers. Think NEXT offers Industrial Training in the field of
CSE/IT/Electronics (ECE)/Mechanical/ Civil/Electrical/Aeronautical Engineering, Polytechnic
Diploma students. Think NEXT offers best industrial training or summer training in
Chandigarh Mohali Panchkula region to make students industry-ready. Over the years, with its
hard work, dedication, honesty and teamwork, Think NEXT has become the first choice among
students/job-seekers for best 6 months, 6 weeks, summer training in Chandigarh, Mohali.
PYTHON INTRODUCTION
Python was developed by Guido van Rossum in the late eighties and early nineties at the National
Research Institute for Mathematics and Computer Science in the Netherlands. Python is derived
from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, and Unix
shell and other scripting languages. Python is copyrighted. Like Perl, Python source code is now
available under the GNU General Public License (GPL). Python is now maintained by a core
development team at the institute, although Guido van Rossum still holds a vital role in directing
its progress.
3
• Web and Internet development (e.g., Django and Pyramid frameworks, Flask and Bottle
micro-frameworks)
• Scientific and numeric computing (e.g., SciPy – a collection of packages for the purposes
of mathematics, science, and engineering; Ipython – an interactive shell that features
editing and recording of work sessions)
• Education (it’ s a brilliant language for teaching programming!)
• Desktop GUIs (e.g., wxWidgets, Kivy, Qt)
• Software Development (build control, management, and testing – Scons, Buildbot,
Apache Gump, Roundup, Trac)
• Business applications (ERP and e-commerce systems – Odoo, Tryton)
• Games (e.g., Battlefield series, Sid Meier\’ s Civilization IV…), websites and services
(e.g., Dropbox, UBER, Pinterest , BuzzFeed…)
Chapter-3
Data Types
The data type of a variable or object determines which operations can be applied to it. Once a
variable is assigned a data type, it can be used for computations in the program. The best thing
about Python is that the data type doesn’ t need to be defined when declaring a variable. Data
types exist, but the variables are not bound to any of them. Languages that act in this way are
called dynamically typed languages.
3.1 Primitive data types: Data types which are pre-defined and supported by the programming
language.
• Integers – This value is represented by int class. It contains positive or negative whole
numbers (without fraction or decimal). In Python there is no limit to how long an integer
value can be.
• Float – This value is represented by float class. It is a real number with floating point
representation. It is specified by a decimal point. Optionally, the character e or E
followed by a positive or negative integer may be appended to specify scientific
notation.
• String Data Types- In python programming, string data types is used to represent
collection of characters. Characters can be any alphabets, digits and special characters.
Example of strings are 'welcome to python', 'hello 123', '@#$$$' etc.
• Boolean Data Types- Data type with one of the two built-in values, True or False.
Boolean objects that are equal to True are truthy (true), and those equal to False are
falsy (false). But non-Boolean objects can be evaluated in Boolean context as well and
determined to be true or false. It is denoted by the class bool.
3.2 Non-Primitive Data types : Data types which are derived from the primitive data types
and offer increased functionality .
• Set :- In Python, Set is an unordered collection of data type that is iterable, mutable and
has no duplicate elements. The order of elements in a set is undefined though it may
consist of various elements.
• Lists : List are just like the arrays, declared in other languages which is a ordered
collection of data. It is very flexible as the items in a list do not need to be of the same
type.
6
• Tuple :- Just like list, tuple is also an ordered collection of Python objects. The only
difference between tuple and list is that tuples are immutable i.e. tuples cannot be
modified after it is created. It is represented by tuple class.
Chapter -4
Operators
Arithmetic operators are used with numeric values to perform common mathematical
operations:
These operators compare the values on either sides of them and decide the relation among
them. They are also called Relational operators.
Python language offers some special types of operator like the identity operator or the
membership operator .
Python’ s membership operators test for membership in a sequence, such as strings, lists,
or tuples. There are two membership operators as explained below
Operator Meaning Example
in True if value/variable is 5 in x
found in the sequence
10
Flow of Control
In Python programming, flow control is the order in which statements or blocks of code are executed at
runtime based on a condition.
The flow control statements are divided into three categories :
a. Conditional statements
b. Iterative statements
c. Transfer statements
In Python, condition statements act depending on whether a given condition is true or false. You can execute
different blocks of codes depending on the outcome of a condition. Condition statements always evaluate to
either True or False.
1. if statement: In control statements, The if statement is the simplest form. It takes a condition and
evaluates to either True or False. If the condition is True, then the True block of code will be
executed, and if the condition is False, then the block of code is skipped, and The controller moves to
the next line.
Syntax:
if condition :
statement 1
statement 2
statement 3
Example
number =7
if number < 10 :
print(number*number)
print('thank you')
Output
49
thank you
[Program finished]
12
2. if-else statement: The if-else statement checks the condition and executes the if block of code when
the condition is True , and if the condition is False, it will execute the else block of code.
Syntax:
if condition :
statement 1
else :
statement 2
Example
x=12
if x%2==0:
print("even")
else :
print("odd")
Output
even
[Program finished]
3. if-elif-else: In Python, the if-elif-else condition statement has an elif blocks to chain multiple
conditions one after another. This is useful when you need to check multiple conditions. With the
help of if-elif-else we can make a tricky decision. The elif statement checks multiple conditions one
by one and if the condition fulfills, then executes that code.
Syntax:
if condition 1:
statement 1
elif condition 2:
statement 2
else :
statement
Example
[Program finished]
4. nested-if : In Python, the nested if-else statement is an if statement inside another if-else statement. It
is allowed in Python to put any number of if statements in another if statement. Indentation is the only
way to differentiate the level of nesting. The nested if-else is useful when we want to make a series of
decisions.
Syntax:
if condition_outer:
if condition_inner :
statement of inner if
else:
statement of inner else
statement of outer if
else:
statement of outer else
Example :
num=15
if num > 0:
if num==0:
print ("zero")
else :
print ("positive")
else :
print("negative")
Output
positive
[Program finished]
14
In Python, iterative statements allow us to execute a block of code repeatedly as long as the condition is
True. We also call it a loop statements.
Python provides us the following two loop statement to perform some actions repeatedly
for loop: Using for loop, we can iterate any sequence or iterable variable. The sequence can be string, list,
dictionary, set, or tuple.
Syntax:
for element in sequence:
body for loop
Example
for i in range(1,10):
print(i)
Output
1
2
3
4
5
6
7
8
9
[Program finished]
while loop: In Python, The while loop statement repeatedly executes a code block while a particular
condition is true. In while loop ,every time the condition is checked at the beginning of the loop , and if it is
true , then loop’ s body gets executed . when the condition became False , the controller comes out of the
block.
Syntax
while condition :
body for the loop
Example
num=10
sum=0
i=1
while i <=num:
sum = sum+i
i=i+1
15
[Program finished]
In Python, transfer statements are used to alter the program’ s way of execution in a certain manner. For this
purpose, we use three types of transfer statements.
break statement:- The break statement is used inside the loop to exit out of the loop. It is useful when we
want to terminate the loop as soon as the condition is fulfilled instead of doing the remaining iterations. It
reduces execution time. Whenever the controller encountered a break statement, it comes out of that loop
immediately.
Example
for x in range(10):
if x > 6:
print ("stop processing")
break
print(x)
Output
0
1
2
3
4
5
6
stop processing
[Program finished]
continue statement:- The continue statement is used to skip the current iteration and continue with the next
iteration.
Example
16
Output
3
4
5
7
[Program finished]
pass statements:- The pass is the keyword In Python, which won’ t do anything. Sometimes there is a
situation in programming where we need to define a syntactically empty block. We can define that block
with the pass keyword. A pass statement is a Python null statement. When the interpreter finds a pass
statement in the program, it returns no operation. Nothing happens when the pass statement is executed. It is
useful in a situation where we are implementing new methods or also in exception handling. It plays a role
like a placeholder.
Example
months=['january','march','may','june']
for mon in months:
pass
print(months)
Output
[Program finished]
17
Chapter 6
Function
A function is a block of code that only runs when it is called. Python functions return a value using a return
statement, if one is specified. A function can be called anywhere after the function has been declared. By
itself, a function does nothing. But, when you need to use a function, you can call it, and the code within the
function will be executed.
Advantages of functions
• Using functions, we can avoid rewriting the same logic/code again and again in a program.
• We can call Python functions multiple times in a program and anywhere in a program.
• We can track a large Python program easily when it is divided into multiple functions.
• Reusability is the main achievement of Python functions.
• However, Function calling is always overhead in a Python program.
The syntax of lambda functions contains only a single statement, which is as follows −
lambda [arg1 [,arg2,.....argn]]:
a. Map function :- The map() function iterates through all items in the given iterable and executes the
function we passed as an argument on each of them.
Syntax
map (function, iterable(s))
We can pass as many iterable objects as we want after passing the function we want to use:
b. Filter function :- Similar to map(), filter() takes a function object and an iterable and creates a new
list. As the name suggests, filter() forms a new list that contains only elements that satisfy a certain
condition, i.e. the function we passed returns True.
Syntax
filter(function, iterable(s))
18
Defining a function refers to creating the function. This involves writing a block of code that we can call by
referencing the name of our function. A function is denoted by the def keyword, followed by a function
name, and a set of parenthesis.
a. Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).
b. Any input parameters or arguments should be placed within these parentheses. You can also define
parameters inside these parentheses.
c. The first statement of a function can be an optional statement - the documentation string of the
function or docstring.
d. The code block within every function starts with a colon (:) and is indented.
e. 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_ my_function(parameters):
function_block
return expression
Def hello_world():
print("hello world")
# function calling
hello_world()
Output
Hello world
Types of arguments
• Required arguments
• Keyword arguments
• Default arguments
• Variable-length arguments
Required Argument
These are the arguments which are required to be passed at the time of function calling with the exact match
of their positions in the function call and function definition. If either of the arguments is not provided in the
function call, or the position of the arguments is changed, the Python interpreter will show the error.
Default argument
Python allows us to initialize the arguments at the function definition. If the value of any of the arguments is
not provided at the time of function call, then that argument can be initialized with the value given in the
definition even if the argument is not specified at the function call.
In large projects, sometimes we may not know the number of arguments to be passed in advance. In such
cases, Python provides us the flexibility to offer the comma-separated values which are internally treated as
tuples at the function call. By using the variable-length arguments, we can pass any number of arguments.
However, at the function definition, we define the variable-length argument using the *args (star) as
*<variable - name >.
Python allows us to call the function with the keyword arguments. This kind of function call will enable us to
pass the arguments in the random order.
The name of the arguments is treated as the keywords and matched in the function calling and definition. If
the same match is found, the values of the arguments are copied in the function definition.
20
Chapter- 7
OOPS
Object-oriented programming (OOP) is a computer programming model that organizes software design
around data, or objects, rather than functions and logic. An object can be defined as a data field that has
unique attributes and behavior.
OOP focuses on the objects that developers want to manipulate rather than the logic required to manipulate
them. This approach to programming is well-suited for programs that are large, complex and actively
updated or maintained. This includes programs for manufacturing and design, as well as mobile applications;
for example, OOP can be used for manufacturing system simulation software.
Characteristics of OOPS
• Objects
• Class
• Data Hiding
• Data Abstraction
• Encapsulation
• Polymorphism
7.1 Class
A class is a collection of objects. A class contains the blueprints or the prototype from which the objects are
being created. It is a logical entity that contains some attributes and methods.
21
Creating an object
obj = Dog()
This will create an object named obj of the class Dog defined above. Before diving deep into objects and
class let us understand some basic keywords that will we used while working with objects and classes.
7.3 Inheritance
Inheritance is the capability of one class to derive or inherit the properties from another class. The class that
derives properties is called the derived class or base class and the class from which the properties are being
derived is called the base class or parent class.
7.4 Polymorphism
Polymorphism simply means having many forms. For example, we need to determine if the given species of
birds fly or not, using polymorphism we can do this using a single function.
7.5 Encapsulation
Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the
idea of wrapping data and the methods that work on data within one unit. This puts restrictions on accessing
variables and methods directly and can prevent the accidental modification of data. To prevent accidental
change, an object’ s variable can only be changed by an object’ s method. Those types of variables are
known as private variables. A class is an example of encapsulation as it encapsulates all the data that is
member functions, variables, etc.
22
Chapter -8
Constructor
A constructor is the first method that is called on object creation (a concept from Object Orientated
Programming). It is always part of a class (an objects methods are defined in a class). The constructor is
always called when creating a new object. It can be used to initialize class variables and startup routines. The
constructor allows you to set variables for the object immediately.Each class can contain one and only one
constructor.
The constructor is always named def __init__(self):.
def display(self):
print("ID: %d \nName: %s" % (self.id, self.name))
emp1.display()
23
Output
ID: 101
Name: John
ID: 102
Name: David
Parameterized Constructor : The parameterized constructor has multiple parameters along with the self.
Consider the following example
.
Python Default Constructor
When we do not include the constructor in the class or forget to declare it, then that becomes the default
constructor. It does not perform any task but initializes the objects. Consider the following example.
24
Chapter-9
MySQL is one of the most popular database management systems (DBMSs) on the market today. It ranked
second only to the Oracle DBMS in this year’ s DB-Engines Ranking. As most software applications need to
interact with data in some form, programming languages like Python provide tools for storing and accessing
these data sources.
Using the techniques discussed in this tutorial, you’ ll be able to efficiently integrate a MySQL database with
a Python application. You’ ll develop a small MySQL database for a movie rating system and learn how to
query it directly from your Python code.
To get the most out of this tutorial, you should have a working knowledge of Python concepts
like for loops, functions, exception handling, and installing Python packages using pip. You should also have
a basic understanding of relational database management systems and SQL queries
like SELECT, DROP, CREATE, and JOIN.
25
Project (Calculator)
root = Tk()
root.title(“ CALCULATOR” )
def show(n):
global exp
exp = exp+n
st.set(exp)
def calculate():
global exp
rs = eval(exp)
st.set(rs)
exp = ""
st = StringVar()
26
root.mainloop()
OUTPUT
27
Conclusion
We tackled the basics of the Python programming language. This approach should be enough to understand all
the following Python examples. We came across data types ,operators, functions, loops, conditional statement,
constructors and many more which is quiet similar to C, C++ and JAVA .
Trouble shooting of the python code was much easier and understandable. The code was bit easier as no. of
lines was short as compared to other programming languages.
Python is easily readable and maintainable across a wide chain of developers. It is so because it has kicked
one step higher to the programming paradigm. The code which is written resembles 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 doing so. Python supports both function-oriented and structure-oriented programming. It
has features of dynamic memory management which can make use of computational resources efficiently. It
is also compatible with all popular operating systems and platforms. Hence this language can be universally
accepted by all programmers. 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 excess code.
While working on project, we learn many aspects related python which we’ ll follow in further projects too.
28
Bibliography
REFRENCES :
1. https://www.guru99.com/python-arrays.html
2. https://pynative.com/python-control-flow-statements/
3. https://www.javatpoint.com/python-functions
4. https://www.geeksforgeeks.org/python-oops-concepts/
5. https://pythonprogramminglanguage.com/constructor/
29