SlideShare ist ein Scribd-Unternehmen logo
1 von 51
PYTHON TRAINING
FROM INTERNSHALA
INTRODUCTION
• Name :- Kunal Chauhan
• Roll no :- 18/BEE/025
• College :- Gautam Buddha University
• Topic :- Programming with Python
• Training Duration :- 6 weeks ( 15th May to 26th June)
CONTENTS
• Introduction to Python programming
• Basics of Programming in Python
• Principles of Object-oriented Programming(OOP)
• SQLite Database,
• Developing a GUI with PyQT
• Application of Python in Various Disciplines modules
1. INTRODUCTION TO PYTHON
PROGRAMMING
Python is a popular programming language. It was created by Guido van Rossum, and
released in 1991. Python works on different platforms (Windows, Mac, Linux, Raspberry Pi,
etc.). It has syntax that allows developers to write programs with fewer lines than some
other programming languages
• It is used for:
• web development (server-side),
• software development,
• mathematics,
• system scripting.
Why Python?
• Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
• Python has a simple syntax similar to the English language.
• Python has syntax that allows developers to write programs with fewer lines than some other
programming languages.
• Python runs on an interpreter system, meaning that code can be executed as soon as it is
written. This means that prototyping can be very quick.
• Python can be treated in a procedural way, an object-oriented way or a functional way.
2. BASICS OF PYTHON
Python is available on www.python.org free of cost and easily accessible.
To check whether Python is installed in your PC we can use these command lines in command
prompt
We can perform arithmetic operations in Python IDLE just by using following lines :-
>>>2+3 >>>3-1
5 2
>>>4*6 >>>10/5
24 2
This is python idle in which we can perform various arithmetic operations and by opening a new
file we can make our programs.
Indentation plays a very important role in Python. Many languages doesn’t care of indentation. It refers to the
spaces at the beginning of code line.
The Python Interpreter: -
Python uses interpreter instead of compiler. In this the interpreter reads program line by line, if any error occurs
it will show then and there.
The Print statement and input statement: -
Print(“Hello world”)
X=input(‘Enter your name’)
OPERATORS IN PYTHON
comparison logical
CONDITIONAL STATEMENTS
1.If statement Example: -
2.Else statement
3.Elif statement :- It combines of if and else. this statement used to reduce the
indentation level and make the program less complex.
Loop statements :- these statements are used when we have to operate a block
of code which we have to operate a fixed number of times. We have to give
condition in loop otherwise it will an infinite loop of no use.
There are 2 types of loop in python
(a) for loop (b) while loop
WHILE LOOP
in the example below it will count until the expression doesn’t equals to 0.
For loop: - This loop is basically used for sequences and range function.
in the example given below until the variable x is in the range of 1 to the user
input value the program will execute
PYTHON COLLECTIONS (ARRAYS)
.
• There are four collection data types in the Python programming language:
(a) List: - A list is a collection which is ordered and changeable. In Python lists are written with
square brackets.
Example: - thislist = ["apple", "banana", "cherry"]
(b) Tuple: - A tuple is a collection which is ordered and unchangeable. In Python tuples are
written with round brackets.
Example: - thistuple = ("apple", "banana", "cherry")
(c) Set: - A set is a collection which is unordered and unindexed. In Python, sets are written with
curly brackets.
Example: - thisset = {"apple", "banana", "cherry"}
(d) Dictionary: - A dictionary is a collection which is unordered, changeable and indexed. In
Python dictionaries are written with curly brackets, and they have keys and values.
Example: - thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964}
Functions : - A function is a block of code which only runs when it is called.
You can pass data, known as parameters, into a function. A function can return
data as a result.
• Creating a function: - In Python a function is defined using the def keyword:
def my_function():
print("Hello from a function")
• Calling a function : - To call a function, use the function name followed by parenthesis:
def my_function():
print("Hello from a function")
my_function()
• Arguments: - Information can be passed into functions as arguments.
Arguments are specified after the function name, inside the parentheses. You can add as many
arguments as you want, just separate them with a comma.
Argument or parameter in Function
• There are 2 types of parameters or Arguments
(a) Actual parameters (b) Formal parameters
Actual Parameters: - Actual arguments are values(or variables)/expressions that are used inside the
parentheses of a function call.
Formal Parameters : - Formal arguments are identifiers used in the function definition to represent
corresponding actual arguments.
Global and Local variables
• Local Variables: - Local variables can only be reached within their scope(like func() above).
Like in below program- there are two local variables x and y.
def sum(x,y):
sum = x + y
return sum
print(sum(5, 10))
The variables x and y will only work/used inside the function sum() and they don’t exist outside
of the function. So trying to use local variable outside their scope, might through NameError. So
obviously below line will not work.
• Global Variables: - A global variable can be used anywhere in the program as its scope is the
entire program. Let’s understand global variable with a very simple example –
z = 25
def func():
global z
print(z)
z=20
func()
print(z)
In the above example the variable z can accessed throughout the program. Which means it is a
global variable.
USING FUNCTIONS FROM BUILT IN MODULE
We've seen function and passing values through them but these are small and simple examples of
functions, in real life applications contains thousands of lines of code. And it is impossible for us to find
function from the entire code. To tackle these situations modules are used.
A module is a file containing definition of function , classes, variables, constants and any other python
object. It is used to organize the things. To create module file we have to save the file with .py
extension.
To use the module file we have to tell the program to get the file, the process of telling program to get
the file is known as importing
>>>import module
Built in modules: -
• OS Module: - The functions in this module are used to do Operating system tasks such as
creating directory, searching contents or creating a directory etc.
There are 5 most commonly used function in this module.
• Random module: - The functions in this module depends on the random number generator function
random().
• The most common used functions in this module is : -
• Math module: - Constants are pi and Euler's number , that can be accessed as math.pi and math.e
Trigonometric functions in math module: -
• Degrees()
• Radians()
• Sin()
• Cos()
• Tan()
Logarithmic functions
Representation functions
• Floor()
• Ceil()
CONSTRUCTING OWN MODULE
first we have to save the file containing functions as friends.py that is our own module
PACKAGES
• In package one or more relevant modules can be save. It is basically a folder containing many
module files and it must contains a _init_.py file which is a packaging unit.
• The process of making a package is as follows:-
1. Create a folder
2. Create a sub folder with same name.
3. Place module files inside the subfolder.
4. Create _init_.py file
5. Create setup.py in the parent folder.
We can install these packages by: -
1. Open command prompt
2. Change the directory to the folder
3. Then we have to the command : - pip install
Then the packages are ready to use in any python program in that PC.
3. PRINCIPLE OF OBJECT ORIENTED PROGRAMMING
(OOP)
Objected oriented programming as a discipline has gained a universal following among developers.
Python, an in-demand programming language also follows an object-oriented programming
paradigm. It deals with declaring Python classes and objects which lays the foundation of OOPs
concepts. This article on “object oriented programming python” will walk you through declaring
python classes, instantiating objects from them along with the four methodologies of OOPs.
Object Oriented Programming is a way of computer programming using the idea of “objects” to
represents data and methods. It is also, an approach used for creating neat and reusable code instead
of a redundant one. the program is divided into self-contained objects or several mini-programs.
Every Individual object represents a different part of the application having its own logic and data to
communicate within themselves.
Difference between Object oriented programming and Program oriented programming.
CLASS AND OBJECTS
Classes
• A class is a collection of objects or you can say it is a blueprint of objects defining the common
attributes and behavior. Now the question arises, how do you do that?
• Well, it logically groups the data in such a way that code reusability becomes easy. I can give you
a real-life example- think of an office going ’employee’ as a class and all the attributes related to
it like ’emp_name’, ’emp_age’, ’emp_salary’, ’emp_id’ as the objects in Python.
• Class is defined under a “Class” Keyword.
Example:
class class1(): // class 1 is the name of the class
Objects
Objects are an instance of a class. It is an entity that has state and behavior. In a nutshell, it is an
instance of a class that can access the data.
Syntax: obj = class1()
Here obj is the “object “ of class1.
• Creating an Object and Class in python:
Example:
class employee():
def __init__(self,name,age,id,salary): //creating a function
self.name = name // self is an instance of a class
self.age = age
self.salary = salary
self.id = id
emp1 = employee("harshit",22,1000,1234) //creating objects
emp2 = employee("arjun",23,2000,2234)
print(emp1.__dict__)//Prints dictionary
Essential Features of OOP: -
• Data Encapsulation: - It is the feature that binds the data and functions that
manipulate the data. This keeps data and methods of a class or object safe from
outside interference and misuse.
• Inheritance: - It is the feature that lets you create a new class from a existing class.
• Overrididng: - With inheritance you can create a child class from the parent class. This
feature lets you redefine a parent class method. Like the name you can override a
parent class function or a method in the child class.
• Polymorphism: - In OOP when each child class provides its own implementation of an
abstract function in parent class, its called polymorphism.
4. SQlite DATABASE
SQlite stands for structured query language .
It is type of relational database management system (RDBMS). By which we can create, update, delete, read
data.
Data can be organized by Database. One of the database is Relational Database which contains tables or entity.
The tables in relational database contains attributes and records.
Primary and foreign key:-
• SQlite Studio is the software which was used to create database. This software can be
downloaded from www.sqlitestudio.pl and can be accessed easily and the CRUD ( Create,
retrieve , update , delete ) can be done.
Accessing Database through python
• Python has the standard mechanism to access the Database files called DB-API. Python already contains
sqlite3 module in it, we just have to import the module in our program. We can verify if the below
program creates a database file ,by opening same file in SQLite Studio.
5. Developing GUI using PyQt
• GUI: - It stands for graphical user interface
• CUI : - It stands for character user interface
PyQt
• Qt is the GUI application development framework it is used in several well known
product like Skype VLC etc.
• PyQt is the python binding Qt
To install PyQt we have run a command in command prompt.
We need a Qt designer to create GUI windows. The Qt designer can be installed by given procedure :-
1. Open command line window.
2. Run the command: pip3 install pyqt5-tools==5.9.0.1.2
3. Go to your Python installation folder (assuming it is C:python36)
4. You will find a folder called Lib. You will find designer.exe file in it's sub-directories.
5. Go to the folder C:Python36Libsite-packagespyqt5-tools
6. You can find designer.exe in this folder. Run that file
Qt designer
• After we are done with designing the GUI window then we save it. It will save in .ui extension , we
have to convert this .ui file to a proper python code. For achieving this we have to use command
line utility called pyuic5. We have to save the ui file in the same folder where the pyuic.exe exists.
• After this we can get myui,py file
• Now by Qt designer we can design many types of GUI windows, we can
manage their layouts for using in different types of devices
• Event handler windows can also be designed by this, which basically means
that the window will only work when the user moves the cursor and clicks the
buttons.
6. APPLICATION OF PYTHON IN VARIOUS DISCIPLINES MODULES
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.
• 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. Games such as Civilization-IV, Disney’s Toontown Online, Vega Strike etc. have been built
using Python.
• 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.
• 4. Data Science and Data Visualization
• 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.
• 5. Desktop GUI
• We use Python to program desktop applications. It provides the Tkinter library that can be
used to develop user interfaces. There are some other useful toolkits such as the
wxWidgets, Kivy, PYQT that can be used to create applications on several platforms.
• 6. Web Scraping Applications
• Python is a savior when it comes 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 training

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 
Python ppt
Python pptPython ppt
Python ppt
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Summer Internship
Python Summer InternshipPython Summer Internship
Python Summer Internship
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
 
Introduction to python for Beginners
Introduction to python for Beginners Introduction to python for Beginners
Introduction to python for Beginners
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Python programming
Python programmingPython programming
Python programming
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Python basic syntax
Python basic syntaxPython basic syntax
Python basic syntax
 
Introduction to the Python
Introduction to the PythonIntroduction to the Python
Introduction to the Python
 
Python and its Applications
Python and its ApplicationsPython and its Applications
Python and its Applications
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python ppt
Python pptPython ppt
Python ppt
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 

Ähnlich wie Python training

pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxRohitKumar639388
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsRuth Marvin
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python ProgrammingDozie Agbo
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdflailoesakhan
 
Using Python Libraries.pdf
Using Python Libraries.pdfUsing Python Libraries.pdf
Using Python Libraries.pdfSoumyadityaDey
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsShanmuganathan C
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfExaminationSectionMR
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonRanjith kumar
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answerskavinilavuG
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptxHaythamBarakeh1
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answersRojaPriya
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfSudhanshiBakre1
 
Modules and Packages in Python Programming Language.pptx
Modules and Packages in Python Programming Language.pptxModules and Packages in Python Programming Language.pptx
Modules and Packages in Python Programming Language.pptxarunavamukherjee9999
 
Python presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, BiharPython presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, BiharUttamKumar617567
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxAmitSingh770691
 

Ähnlich wie Python training (20)

pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_arguments
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdfProgFund_Lecture_4_Functions_and_Modules-1.pdf
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
 
Using Python Libraries.pdf
Using Python Libraries.pdfUsing Python Libraries.pdf
Using Python Libraries.pdf
 
OODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objectsOODP Unit 1 OOPs classes and objects
OODP Unit 1 OOPs classes and objects
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdf
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
 
Python Course.docx
Python Course.docxPython Course.docx
Python Course.docx
 
M.c.a (sem iii) paper - i - object oriented programming
M.c.a (sem   iii) paper - i - object oriented programmingM.c.a (sem   iii) paper - i - object oriented programming
M.c.a (sem iii) paper - i - object oriented programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Dive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdfDive into Python Functions Fundamental Concepts.pdf
Dive into Python Functions Fundamental Concepts.pdf
 
Modules and Packages in Python Programming Language.pptx
Modules and Packages in Python Programming Language.pptxModules and Packages in Python Programming Language.pptx
Modules and Packages in Python Programming Language.pptx
 
Python presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, BiharPython presentation of Government Engineering College Aurangabad, Bihar
Python presentation of Government Engineering College Aurangabad, Bihar
 
C++ first s lide
C++ first s lideC++ first s lide
C++ first s lide
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
PRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptx
 

Kürzlich hochgeladen

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Kürzlich hochgeladen (20)

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

Python training

  • 2. INTRODUCTION • Name :- Kunal Chauhan • Roll no :- 18/BEE/025 • College :- Gautam Buddha University • Topic :- Programming with Python • Training Duration :- 6 weeks ( 15th May to 26th June)
  • 3.
  • 4. CONTENTS • Introduction to Python programming • Basics of Programming in Python • Principles of Object-oriented Programming(OOP) • SQLite Database, • Developing a GUI with PyQT • Application of Python in Various Disciplines modules
  • 5. 1. INTRODUCTION TO PYTHON PROGRAMMING Python is a popular programming language. It was created by Guido van Rossum, and released in 1991. Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.). It has syntax that allows developers to write programs with fewer lines than some other programming languages • It is used for: • web development (server-side), • software development, • mathematics, • system scripting.
  • 6. Why Python? • Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc). • Python has a simple syntax similar to the English language. • Python has syntax that allows developers to write programs with fewer lines than some other programming languages. • Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick. • Python can be treated in a procedural way, an object-oriented way or a functional way.
  • 7. 2. BASICS OF PYTHON Python is available on www.python.org free of cost and easily accessible. To check whether Python is installed in your PC we can use these command lines in command prompt We can perform arithmetic operations in Python IDLE just by using following lines :- >>>2+3 >>>3-1 5 2 >>>4*6 >>>10/5 24 2
  • 8. This is python idle in which we can perform various arithmetic operations and by opening a new file we can make our programs.
  • 9. Indentation plays a very important role in Python. Many languages doesn’t care of indentation. It refers to the spaces at the beginning of code line. The Python Interpreter: - Python uses interpreter instead of compiler. In this the interpreter reads program line by line, if any error occurs it will show then and there. The Print statement and input statement: - Print(“Hello world”) X=input(‘Enter your name’)
  • 13. 3.Elif statement :- It combines of if and else. this statement used to reduce the indentation level and make the program less complex.
  • 14. Loop statements :- these statements are used when we have to operate a block of code which we have to operate a fixed number of times. We have to give condition in loop otherwise it will an infinite loop of no use. There are 2 types of loop in python (a) for loop (b) while loop
  • 15. WHILE LOOP in the example below it will count until the expression doesn’t equals to 0.
  • 16. For loop: - This loop is basically used for sequences and range function. in the example given below until the variable x is in the range of 1 to the user input value the program will execute
  • 17. PYTHON COLLECTIONS (ARRAYS) . • There are four collection data types in the Python programming language: (a) List: - A list is a collection which is ordered and changeable. In Python lists are written with square brackets. Example: - thislist = ["apple", "banana", "cherry"] (b) Tuple: - A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Example: - thistuple = ("apple", "banana", "cherry") (c) Set: - A set is a collection which is unordered and unindexed. In Python, sets are written with curly brackets. Example: - thisset = {"apple", "banana", "cherry"} (d) Dictionary: - A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. Example: - thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964}
  • 18. Functions : - A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.
  • 19. • Creating a function: - In Python a function is defined using the def keyword: def my_function(): print("Hello from a function") • Calling a function : - To call a function, use the function name followed by parenthesis: def my_function(): print("Hello from a function") my_function() • Arguments: - Information can be passed into functions as arguments. Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.
  • 20. Argument or parameter in Function
  • 21. • There are 2 types of parameters or Arguments (a) Actual parameters (b) Formal parameters Actual Parameters: - Actual arguments are values(or variables)/expressions that are used inside the parentheses of a function call. Formal Parameters : - Formal arguments are identifiers used in the function definition to represent corresponding actual arguments.
  • 22. Global and Local variables • Local Variables: - Local variables can only be reached within their scope(like func() above). Like in below program- there are two local variables x and y. def sum(x,y): sum = x + y return sum print(sum(5, 10)) The variables x and y will only work/used inside the function sum() and they don’t exist outside of the function. So trying to use local variable outside their scope, might through NameError. So obviously below line will not work. • Global Variables: - A global variable can be used anywhere in the program as its scope is the entire program. Let’s understand global variable with a very simple example –
  • 23. z = 25 def func(): global z print(z) z=20 func() print(z) In the above example the variable z can accessed throughout the program. Which means it is a global variable.
  • 24. USING FUNCTIONS FROM BUILT IN MODULE We've seen function and passing values through them but these are small and simple examples of functions, in real life applications contains thousands of lines of code. And it is impossible for us to find function from the entire code. To tackle these situations modules are used. A module is a file containing definition of function , classes, variables, constants and any other python object. It is used to organize the things. To create module file we have to save the file with .py extension. To use the module file we have to tell the program to get the file, the process of telling program to get the file is known as importing >>>import module
  • 26. • OS Module: - The functions in this module are used to do Operating system tasks such as creating directory, searching contents or creating a directory etc. There are 5 most commonly used function in this module.
  • 27. • Random module: - The functions in this module depends on the random number generator function random(). • The most common used functions in this module is : -
  • 28. • Math module: - Constants are pi and Euler's number , that can be accessed as math.pi and math.e
  • 29. Trigonometric functions in math module: - • Degrees() • Radians() • Sin() • Cos() • Tan()
  • 32. CONSTRUCTING OWN MODULE first we have to save the file containing functions as friends.py that is our own module
  • 33. PACKAGES • In package one or more relevant modules can be save. It is basically a folder containing many module files and it must contains a _init_.py file which is a packaging unit. • The process of making a package is as follows:- 1. Create a folder 2. Create a sub folder with same name. 3. Place module files inside the subfolder. 4. Create _init_.py file 5. Create setup.py in the parent folder. We can install these packages by: - 1. Open command prompt 2. Change the directory to the folder 3. Then we have to the command : - pip install Then the packages are ready to use in any python program in that PC.
  • 34. 3. PRINCIPLE OF OBJECT ORIENTED PROGRAMMING (OOP) Objected oriented programming as a discipline has gained a universal following among developers. Python, an in-demand programming language also follows an object-oriented programming paradigm. It deals with declaring Python classes and objects which lays the foundation of OOPs concepts. This article on “object oriented programming python” will walk you through declaring python classes, instantiating objects from them along with the four methodologies of OOPs. Object Oriented Programming is a way of computer programming using the idea of “objects” to represents data and methods. It is also, an approach used for creating neat and reusable code instead of a redundant one. the program is divided into self-contained objects or several mini-programs. Every Individual object represents a different part of the application having its own logic and data to communicate within themselves.
  • 35. Difference between Object oriented programming and Program oriented programming.
  • 36. CLASS AND OBJECTS Classes • A class is a collection of objects or you can say it is a blueprint of objects defining the common attributes and behavior. Now the question arises, how do you do that? • Well, it logically groups the data in such a way that code reusability becomes easy. I can give you a real-life example- think of an office going ’employee’ as a class and all the attributes related to it like ’emp_name’, ’emp_age’, ’emp_salary’, ’emp_id’ as the objects in Python. • Class is defined under a “Class” Keyword. Example: class class1(): // class 1 is the name of the class Objects Objects are an instance of a class. It is an entity that has state and behavior. In a nutshell, it is an instance of a class that can access the data. Syntax: obj = class1() Here obj is the “object “ of class1.
  • 37. • Creating an Object and Class in python: Example: class employee(): def __init__(self,name,age,id,salary): //creating a function self.name = name // self is an instance of a class self.age = age self.salary = salary self.id = id emp1 = employee("harshit",22,1000,1234) //creating objects emp2 = employee("arjun",23,2000,2234) print(emp1.__dict__)//Prints dictionary
  • 38. Essential Features of OOP: - • Data Encapsulation: - It is the feature that binds the data and functions that manipulate the data. This keeps data and methods of a class or object safe from outside interference and misuse. • Inheritance: - It is the feature that lets you create a new class from a existing class. • Overrididng: - With inheritance you can create a child class from the parent class. This feature lets you redefine a parent class method. Like the name you can override a parent class function or a method in the child class. • Polymorphism: - In OOP when each child class provides its own implementation of an abstract function in parent class, its called polymorphism.
  • 39. 4. SQlite DATABASE SQlite stands for structured query language . It is type of relational database management system (RDBMS). By which we can create, update, delete, read data. Data can be organized by Database. One of the database is Relational Database which contains tables or entity. The tables in relational database contains attributes and records.
  • 41. • SQlite Studio is the software which was used to create database. This software can be downloaded from www.sqlitestudio.pl and can be accessed easily and the CRUD ( Create, retrieve , update , delete ) can be done.
  • 42. Accessing Database through python • Python has the standard mechanism to access the Database files called DB-API. Python already contains sqlite3 module in it, we just have to import the module in our program. We can verify if the below program creates a database file ,by opening same file in SQLite Studio.
  • 43. 5. Developing GUI using PyQt • GUI: - It stands for graphical user interface • CUI : - It stands for character user interface
  • 44. PyQt • Qt is the GUI application development framework it is used in several well known product like Skype VLC etc. • PyQt is the python binding Qt To install PyQt we have run a command in command prompt.
  • 45. We need a Qt designer to create GUI windows. The Qt designer can be installed by given procedure :- 1. Open command line window. 2. Run the command: pip3 install pyqt5-tools==5.9.0.1.2 3. Go to your Python installation folder (assuming it is C:python36) 4. You will find a folder called Lib. You will find designer.exe file in it's sub-directories. 5. Go to the folder C:Python36Libsite-packagespyqt5-tools 6. You can find designer.exe in this folder. Run that file
  • 47. • After we are done with designing the GUI window then we save it. It will save in .ui extension , we have to convert this .ui file to a proper python code. For achieving this we have to use command line utility called pyuic5. We have to save the ui file in the same folder where the pyuic.exe exists. • After this we can get myui,py file
  • 48. • Now by Qt designer we can design many types of GUI windows, we can manage their layouts for using in different types of devices • Event handler windows can also be designed by this, which basically means that the window will only work when the user moves the cursor and clicks the buttons.
  • 49. 6. APPLICATION OF PYTHON IN VARIOUS DISCIPLINES MODULES 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. • 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. Games such as Civilization-IV, Disney’s Toontown Online, Vega Strike etc. have been built using Python. • 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.
  • 50. • 4. Data Science and Data Visualization • 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. • 5. Desktop GUI • We use Python to program desktop applications. It provides the Tkinter library that can be used to develop user interfaces. There are some other useful toolkits such as the wxWidgets, Kivy, PYQT that can be used to create applications on several platforms. • 6. Web Scraping Applications • Python is a savior when it comes 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.