[go: up one dir, main page]

0% found this document useful (0 votes)
14 views41 pages

Summer Training Report: Python and Machine Learning Using Python

Uploaded by

shivansh bohra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views41 pages

Summer Training Report: Python and Machine Learning Using Python

Uploaded by

shivansh bohra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 41

SUMMER TRAINING REPORT

ON

Python and Machine learning using python

 Under the site of INTERNSHALA.COM

Done by :-

SHIVANSH BOHRA

17001004054

MECHANICAL Engineering

Submitted To :-

DR.ANIL NARWAL

Department of Electrical Engineering , Deenbandhu Chhotu Ram


University of Science and Technology Murthal

PREFACE
The objective of a practical training is to learn something
about industries practically and to be familiar with a
working style of a technical worker to adjust simply
according to industrial environment. As a part of
academic syllabus of four year degree course in ME, every
student is required to undergo practical training of days.
We are student of 3rd year ME and this report is written
on the basis of practical knowledge acquired by me during
the period of practical training taken from “INTERNSHALA
Trainings”.
This report deals with the equipments their relation and
their general operating principle. Sincere efforts have
been made to present this report on Programming with
python.
Inspire of all our best efforts, some unintentional errors
might have eluded, it is requested to neglect them.
ABSTRACT
The objective of a practical training is to learn something
about industries practically and to be familiar with a
working style of a technical worker to adjust simply
according to industrial environment . This report deals
with the equipments their relation and their general
operating principle.
Python, an interpreted language which was developed by
Guido van Rossum came into implementation in 1989.
The language supports both object oriented and
procedure oriented approach. Python is designed to be a
highly extensible language. Python works on the principle
of “there is only one obvious way to do a task” rather
than “there is more than one way to solve a particular
problem”. Python is very easy to learn and implement.
The simpler syntax, uncomplicated semantics and
approach with which Python has been developed makes it
very easier to learn. A large number of python
implementations and extensions have been developed
since its inception.
Training Cover provides both six weeks as well as six
months training in Python. Python is divided into two
parts as “Core Python” and “Advance Python”.
INDEX
INTRODUCTION

 PYTHON :
Python is a high-level, interpreted, interactive and object-oriented
scripting language. Python is designed to be highly readable. It uses
English keywords frequently where as other languages use
punctuation, and it has fewer syntactical constructions than other
languages.

 Python is Interpreted: Python is processed at runtime by the


interpreter. You do not need to compile your program before
executing it. This is similar to PERL and PHP.

 Python is Interactive: You can actually sit at a Python prompt


and interact with the interpreter directly to write your
programs.

 Python is Object-Oriented: Python supports Object-Oriented


style or technique of programming that encapsulates code
within objects.

 Python is a Beginner's Language: Python is a great language


for the beginner-level programmers and supports the
development of a wide range of applications from simple text
processing to WWW browsers to games.

History of Python :

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, 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.

Python Features :
Python's features include:

 Easy-to-learn: Python has few keywords, simple


structure, and a clearly defined syntax. This allows the
student to pick up the language quickly.

 Easy-to-read: Python code is more clearly defined and


visible to the eyes.

 Easy-to-maintain: Python's source code is fairly easy-to-


maintain.

 A broad standard library: Python's bulk of the library is very


portable and cross-platform compatible on UNIX, Windows,
and Macintosh.
 Interactive Mode: Python has support for an interactive mode
which allows interactive testing and debugging of snippets of
code.
 Portable: Python can run on a wide variety of hardware
platforms and has the same interface on all platforms.
 Extendable:You can add low-level modules to the Python
interpreter. These modules enable programmers to add to or
customise their tools to be more efficient.

 Databases: Python provides interfaces to all major


commercial databases.

 GUI Programming: Python supports GUI applications that can


be created and ported to many system calls, libraries and
windows systems, such as Windows MFC, Macintosh, and the
X Window system of Unix.

 Scalable: Python provides a better structure and support for


large programs than shell scripting.

Python has a big list of good features:

 It supports functional and structured programming methods as


well as OOP.
 It can be used as a scripting language or can be compiled to
byte-code for building large applications.
 It provides very high-level dynamic data types and supports
dynamic type checking.
 IT supports automatic garbage collection.
 It can be easily integrated with C, C++, COM, ActiveX, CORBA,
and Java.
Chapter 2

OPERATORS
Arithmetic operators:
Python operator Precedence
Chapter 3

COLLECTION IN PYTHON

3.1 LIST
The list is a most versatile data type available in Python which can be
written as a list of comma-separated values (items) between square
brackets. Important thing about a list is that items in a list need not
be of the same type.
Creating a list is as simple as putting different comma-separated
values between square brackets. For example –

list1 = ['physics', 'chemistry', 1997, 2000];


list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"]

Basic List Operations


Lists respond to the + and * operators much like strings; they mean
concatenation and repetition here too, except that the result is a
new list, not a string.
Basic syntax of Python
Write a program to find out the number is divisible by 2 and 3 or not?

Keywords:
Keywords are the reserved words in Python. We cannot use a keyword as a
variable name, function name or any other identifier.
Data Types & Variables:

Numeric:
Python, numeric data type represent the data which has numeric value. Numeric value can be
integer, floating number or even complex numbers. These values are defined
as int, float and complex class in Python.

 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.
 Complex Numbers – Complex number is represented by complex class. It is
specified as (real part) + (imaginary part)j. For example – 2+3j

Sequence Type:
Python, sequence is the ordered collection of similar or different data types.
Sequences allows to store multiple values in an organised and efficient fashion.
There are several sequence types in Python –

 String
 List
 Tuple

1) String 
In Python, Strings are arrays of bytes representing Unicode characters. A string is a collection
of one or more characters put in a single quote, double-quote or triple quote. In python there
is no character data type, a character is a string of length one. It is represented by str class.

2) List 
Lists 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.

3) Tuple 
Just like list, tuple is also an ordered collection of Python objects. The only difference
between type and list is that tuples are immutable i.e. tuples cannot be modified after it is
created. It is represented by tuple class.
 

Boolean
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.

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

Dictionary
Dictionary in Python is an unordered collection of data values, used to store data values like a
map, which unlike other Data Types that hold only single value as an element, Dictionary
holds key:value pair. Key-value is provided in the dictionary to make it more optimised.
Each key-value pair in a Dictionary is separated by a colon :, whereas each key is separated
by a ‘comma’.
Mutability: The property of whether or not data objects can be
modified in the same memory location where they are stored is called
Mutuablity.
Numeric Data types:

String data types:

\t Adds a horizontal tab >>>print(‘time is a /t


valuable thing’)

\\ Print a backslash >>>print(‘watch it fly


by \\ as the
pendulum swings

\’ Prints a single quote >>>print(‘it doesn\’t


even matter how
hard you try.

\’’ Prints a double >>>print(‘It is so \’’


quote unreal\’’)

Methods for string procession:


1) Capitalize() 5)count()
2) Upper() 6) index()
3) Lower() 7) islower() and so on.
4) Title()

For example:
Set operations:
There are a large number of set operations, including
union (|), intersection (&), difference (-), symmetric
difference (^). These are unusual operations, so we'll look
at them in some detail. In addition to this operator
notation, there are method functions which do the same
things.We'll look at the method function versions
below.We'll use the following two sets to show these
operators.

>>>
fib=set( (1,1,2,3,5,8,13) )

>>>
prime=set( (2,3,5,7,11,13) )
Union, |

The resulting set has elements from both


source sets. An element is in the result if it is
one set or the other.

>>>
fib | prime

set([1, 2, 3, 5, 7, 8, 11, 13])

Figure 1. Set Union, S1|S2

Intersection, &

The resulting set has elements that are common to


both source sets. An element is in the result if it is in
one set and the other.

>>>
fib & prime

set([2, 3, 5, 13])

Figure 2. Set Intersection, S1&S2


Difference, -

The resulting set has elements of the left-


hand set with all elements from the right-
hand set removed. An element will be in the result
if it is in the left-hand set and not in the right-
hand set.

>>> fib - prime


set([8, 1])
>>> prime - fib
set([11, 7])

Figure 3. Set Difference, S1-S2

Symmetric Difference, ^

The resulting set has elements which are unique


to each set. An element will be in the result set if
either it is in the left-hand set and not in the
right-hand set or it is in the right-hand set and
not in the left-hand set

>>>
fib ^ prime

set([8, 1, 11, 7])

Figure 4. Set Symmetric Difference, S2^S2

Manipulating lists: we can modify the items


within the list.Modifying a list means to change an item ,or
add a new item , or remove an existing item. Here are some
methods of built- in list class that help in modifying lists.
1) Append() 4) remove()
2) Insert() 5) reverse()
3) Pop() 6) sort()

Append() :
Conditional statements: A statement that controls the flow of execution
depending on some condition.
 1)if Statement is used for decision-making operations. It contains a body of code
which runs only when the condition given in the if statement is true. If the
condition is false, then the optional else statement runs which contains some code
for the else condition.

Syntax: 

if expression
Statement
else
Statement

How to use "else condition"


The "else condition" is usually used when you have to judge one statement on the
basis of other. If one condition goes wrong, then there should be another condition
that should justify the statement or logic

How to use "elif" condition


To correct the previous error made by "else condition", we can
use "elif"statement. By using "elif" condition, you are telling the program to print
out the third condition or possibility when the other condition goes wrong or
incorrect.
Using loops: A loop statement allows us to execute a
statement or group of statements multiple times.

Example: Write a program to calculate the factorial of a number?

By Using Functions:
In Python, a function is a group of related statements that performs a specific task.

Functions help break our program into smaller and modular chunks. As our
program grows larger and larger, functions make it more organised and
manageable. Furthermore, it avoids repetition and makes the code reusable.

Using functions from built - in modules:

Some functions:
Overview of Object Oriented Language:

 Classes: are blueprints of objects.


 Essentual Features of OOP:
1)Data encapsulation: It is the feature that binds together the

data and functions that manipulates the data.This keeps both


data and methods of class or object safe from outside
interference and misuse.
2)Polymorphism: In OOP, when each child class provides its
own implementation of an abstract function in parent class, it’s
called polymorphism.
3)Inheritance: It is the feature that lets you create a new class
from an existing class.
4)Overriding: It is the feature that lets you redefine a parent
class method. Like the name suggests, you can override a
parent class function or a method in the child class.
 Introduction to SQL :
 Structure Query Language(SQL) is a database query language used
for storing and managing data in Relational DBMS. SQL was the
first commercial language introduced for Relational model of
database.
 It is a standard language for Relational Database System. It
enables a user to create, read, update and delete relational
databases and tables.

DDL: Data Definition Language:


This includes changes to the structure of the table like creation of table, altering
table, deleting a table etc.
All DDL commands are auto-committed. That means it saves all the changes
permanently in the database.
TCL: Transaction Control Language:
These commands are to keep a check on other commands and their affect on the
database. These commands can annul changes made by other commands by rolling
the data back to its original state. It can also make any temporary change
permanent.

Table : A table is a data structure that organises information into rows


and columns. It can be used to both store and display data in a
structured format. For example, databases store data in tables so that
information can be quickly accessed from specific rows.

Primary key: It uniquely identifies each record in a table. Primary keys must


contain UNIQUE values, and cannot contain NULL values. A table can have
only ONE primary key; and in the table, this primary key can consist of
single or multiple columns (fields).

Foreign key: It is a key used to link two tables together. A FOREIGN KEY is
a field (or collection of fields) in one table that refers to the PRIMARY KEY in
another table.

Creating a SQULite database:


SQL Statements:

Code & output:

Some Methods:
Creating a database:
Difference between COMMIT and ROLLBACK in SQL
1. COMMIT :
COMMIT in SQL is a transaction control language which is used to permanently save the
changes done in the transaction in tables/databases. The database cannot regain its previous
state after the execution of it.

2. ROLLBACK :
ROLLBACK in SQL is a transactional control language which is used to undo the
transactions that have not been saved in database. The command is only be used to
undo changes since the last COMMIT.

GUI and Event Driven Programming:


Common widgets:

Widgets Description
Application A container widget inside which other
window elements are arranged .
Button An area on which a mouse click triggers
some operations.
Text box Reads text input from keyboard.
Radio Button Allows a user to select one of several
options .
List box / drop Presents a selectable list of items .
down list
Checkbox Allows a user to select one or more of
several options .

 Simple GUI applications using PyQt :


Layout Manager:

A layout manager is an object that implements the LayoutManager


interface and determines the size and position of the components within a
container. Although components can provide size and alignment hints, a
container's layout manager has the final say on the size and position of
the components within the container.

This is the base class of geometry managers. This is an abstract


base class inherited by the concrete classes QBoxLayout, QGridLayout,
QFormLayout, and QStackedLayout .

Using common widgets:


1. QRadioButton
2. QCheckBox
3. QComboBox
4. QPushButton

QListWidget :
QListWidget class is an item-based interface to add or
remove items from a list. Each item in the list is a
QListWidgetItem object. ListWidget can be set to be multi-
selectable.
Following are the frequently used methods of QListWidget
class:
Python Applications:
Python supports cross-platform operating systems which makes building
applications with it all the more convenient. Some of the globally known applications
such as YouTube, BitTorrent, DropBox, etc. use Python to achieve their functionality.

1. Web Development :

Python can be used to make web-applications at a rapid rate. Why is that? It is


because of the frameworks Python uses to create these applications. There
is common-backend logic that goes into making these frameworks and a number of
libraries that can help integrate protocols such as HTTPS, FTP, SSL etc. and even
help in the processing of JSON, XML, E-Mail and so much more. 

Some of the most well-known frameworks are Django, Flask, Pyramid. Why use a


framework? The security, scalability, convenience that they provide is
unparalleled compared to starting the development of a website from scratch.

2. Game Development :

Python is also used in the development of interactive games. There are libraries
such as PySoy which is a 3D game engine supporting Python 3, PyGame which
provides functionality and a library for game development.

3. Machine Learning and Artificial Intelligence:

Machine Learning and Artificial Intelligence are the talks of the town as they yield the
most promising careers for the future. We make the computer learn based on past
experiences through the data stored or better yet, create algorithms which makes the
computer learn by itself. The programming language that mostly everyone chooses?
It’s Python. Why? Support for these domains with the libraries that exist already .

4. Data Science and Data Visualisation :

Data is money if you know how to extract relevant information which can help you
take calculated risks and increase profits. You study the data you have, perform
operations and extract the information required. Libraries such as Pandas, NumPy
help you in extracting information. 

You can even visualise the data libraries such as Matplotlib, Seaborn, which are
helpful in plotting graphs and much more. This is what Python offers you to
become a Data Scientist.
5. Desktop GUI :

Python can be used to program desktop applications. It provides the Tkinter library


that can be used to develop user interfaces. There are some other useful toolkits.,
PYQT that can be used to create applications on several platforms.

You can start out with creating simple applications such as Calculators, To-Do apps
and go ahead and create much more complicated applications.

6. Web Scraping Applications :

Python can be used to pull a large amount of data from websites which can then be
helpful in various real-world processes such as price comparison, job listings,
research and development and much more. 

Python has a library called BeautifulSoup which can be used to pull such data and
be used accordingly. Here’s a full-fledged guide to learn Web scraping with Python.

7. CAD Applications:

Computer-Aided Designing is a very complicated application to make as many things have to


be taken care of. Objects and their representation, functions are just the tip of the iceberg
when it comes to something like this. Python makes this simple too and the most well-known
application for CAD is Fandango.
8. Embedded Applications :

Python is based on C which means that it can be used to create Embedded C software for
embedded applications. This helps us to perform higher-level applications on smaller devices
which can compute Python. 

The most well-known embedded application could be the Raspberry Pi which uses


Python for its computing. It can be used as a computer or like a simple embedded
board to perform high-level computations.

9. Audio and Video Applications :

Python can be used to develop applications that can multi-task and also output
media. Video and audio applications such as TimPlayer have been developed using
Python libraries and they provide better stability and performance compared to other
media players.

Python has a variety of applications where it can be used. No matter what field you
take up, Python is rewarding. So I hope you have understood the Python
Applications and what sets Python apart from every other programming language.
BIBLIOGRAPHY
 Training Manual :
 https://trainings.internshala.com
Certificate

You might also like