SlideShare a Scribd company logo
One Day Workshop
on
Python
Devashish Kumar
Faculty-IT
iNurture
Programming Language
 A programming language is a notation for writing programs.
 A programming language is a computer language designed to
communicate instructions to a machine, particularly a computer.
 Programming languages can be used to create programs, to control the
behaviour of a machine or to express algorithms.
 Various programming languages are such as: c , c++ , R, java, C# , ruby , python
etc.
What is Python ?
Python is a high level programming language which is:
Interpreted
Interactive
Object-Oriented
Dynamic programming language
Open source model
WHY PYTHON ?
Python is nowadays widely used as an programming language. It has :-
 Simple syntax
 One-Line command
 English like commands(easily readable)
 Dynamically Typed
 Easily Indentable
 Intuitive data structures like tuples, sets, dictionaries,strings,lists etc
Applications of Python language
Python language used in:
– Web Development
– Database programming
– Game Development
– Scientific Computing
– Web Framework
– Molecular Biology
WHY 2.7 RELEASE AFTER 3.X ?
• Version 2.X has an awful quantity of useful libraries that haven’t been ported
to 3.X version.
• Current Linux distributions and Macs are still using 2.x as default. Some
are phasing out Python 2 as preinstalled default.
• Python 3 already broadly supports creating GUI applications, with Tkinter
,etc. in the standard library.
• Python 2.7 provides a stable and a supported base platform for production
system that have not yet been ported to Python 3.
 In Python 2.X, range() and xrange() function is used for
iterating and range() function behaves as it is a list.
 In Python 2.X, data type returned is in int,char etc.
 In python 2.X, no TypeError is raised if we try to
compare unorderable type.
 Handling exception: In python 2.X, for handling
exception in the syntax we use comma instead of ‘as’.
 In python 3.X, xrange() function is not used, it gives
name error and range doesnot behave as a list.
 In python 3.x, data type returned is in class.
 In python 3.X, TypeError is raised as warning if we try
to compare unorderable type.
 In python 3.X, for handling exception in the syntax we
use ‘as’ keyword.
 Packages like NumPy and SciPy,
Django,Flask,CherryPy and Pyramid is not
included in python 2.X.
 Integer Division: Python 2.X treats numbers that
you type without any digit after the decimal point
as integers,which can lead to some unexpected
results.
 Raising Exceptions:
 List comprehension loop variables:
 Packages like NumPy and SciPy,
Django,Flask,CherryPy and Pyramid is ported to
python 3.X .
 Python 3.X evaluates “3/2” as 1.5 by default,which
is more intuitive for programmer.
 Raising exceptions:
 List comprehension loop variables:
 Future_module: this module is used to
help in migration.
 .Next() function: Python 2.X supports
.next() function.
 Output:
 Python 2.x has two integer types: int and
long
 Future Module:
 .Next() function: Python 3.X doesn’t support
“.next()” function.
 In Python 3.x, no long integer type is
specified.
VARIABLES
PYTHON VARIABLES
 A variable is a location in memory used to store some data.
 They are given unique names to differentiate between different memory locations.
 Don't need to declare a variable before using it.
 In Python, simply assign a value to a variable and it will exist. Don’t declare the type of the
variable.
 VARIABLE ASSIGNMENT: We use the assignment operator (=) to assign values to a variable.
 MULTIPLE ASSIGNMENT: In Python, multiple assignments can be made in a single statement.
 We can assign the same value to multiple variables at once.
Assignment
operator
NUMBERS
 Number data types store numeric values.
 They are immutable data types.
 Number objects are created when you assign a value to them.
 We can delete the reference to a number object by using the del statement.
 Syntax: del var1[,var2[,var3[...., varN]]]]
 We can delete a single object or multiple objects by using the del statement.
NUMBERS
 Integer numbers: Integers can be of any length, it is only limited by the
memory available. They are positive or negative whole numbers with no
decimal point.
 Floating point number : It is accurate up to 15 decimal places.
 Complex numbers : These are written in the form, x + yj, where x is the
real part and y is the imaginary part.
 Examples:
Integer
no:
Floating point
no:
Complex
number
EXAMPLES OF NUMBER
 In interactive mode, the last printed expression is assigned to the variable _
 Example:
 Division (/) always returns a float.
 To get an integer result, use floor division (//)
 To calculate the remainder you can use %:
NUMBERS
 Abs(): returns the absolute value of x i.e. the positive distance between x and zero.
 Ceil() : returns the ceiling value of x i.e. the smallest integer not less than x.
 EXP(): returns exponential of x: (e power x).
 Fabs(): returns the absolute value of x. fabs() is defined in math module and
works only on float and integer number.
NUMBERS
• Floor(): returns the floor of x i.e. the largest integer not greater than x.
• Log(): returns the natural logarithm of x.
• Log10(): returns base-10 logarithm of x for x > 0.
• Max(): returns the largest of its arguments
• There are many more functions that perform mathematical operations on
numbers.
NUMBERS
Control Flow And Loops
Various control statements are:
 if and else
 Elif
For
Range
While
Break
Continue
IF AND ELSE STATEMENT
• The syntax for if statement in python are:
• For example:
if (condition): #execution of an if statement
statement1
statement2
else: #execution of an else statement
statement1
statement2
• If we use else statement without using if statement then it will raise an error.
Example of If And Else
Output:
Elif statement
• Elif statement is similar to the else if statement used in c or c++.
• Elif statement is a combination of else and if statement.
• Syntax: if (condition):
statement1
statement2
elif (condition): # elif is a combination of else if
statement3
statement4
else:
statement5
• There can be zero or more elif parts, and the else part is optional. The keyword
‘elif ‘ is short for ‘else if’, and is useful to avoid excessive indentation.
Example of Elif statement
Output:
For Statement
 The for statement in Python differs from in C or C++.
 Python’s for statement iterates over the items of any sequence , in the order that
they appear in the sequence.
 Syntax:
for i in m:
// repeat body for each item in m
Examples of For statement
Output: Output
Example 2:Example1:
Range Function
 Range function is used If we do not want to iterate over a sequence of numbers.
 Range function produces the sequences of values ie i,i+1,……….j-1 if it range(i,j).
 If range(i,j,k) then it increments by k that is i, i+k,……………………….,i+nk.
 Sequence produced by a range is not a list, use list(range(..)) to get a list.
 Why does range(i ,j) stops at j-1?
 to make it easier to process lists
 To iterate over the indices of a sequence, you can combine range() and len() as
follows:
Examples Of Range Function
WHILE LOOP
• While loop in Python is used to iterate over a block of code as long as the test
expression(condition) is true.
• Syntax: while condition:
statement(s) //repeat body till condition becomes false
• Loop might not ever run: When the condition is tested and the result is false then
the loop body will be skipped and the first statement after the while loop is executed.
• Example:
output:
Break Statement
 The break statement in python terminates the current loop and resumes
execution at the next statement , just like break statement in c.
 The break statement can be used in both for and while loops.
Output:
Continue Statement
• Continue statement in Python returns the control to the beginning of the while or
for loop. The continue statement rejects all the remaining statement in the current
iteration of the loop and moves the control back to the top of the loop.
Output:
Pass Statement
 The pass statement is used in Python when statement is required but you do not
want any command or code to execute.
 The pass statement is a null operation means nothing happens when it executes.
Suppose we have a loop or function that is not implemented yet , but we want to
implement it in future. They cannot have an empty body.
 Pass statement is there to create minimal classes.
 It is useful when you have created a code block but it is no longer required.
Comment statement is ignored by interpreter entirely and pass is not ignored.
 Example: output
VARIABLES
CONTRIBUTERS

More Related Content

What's hot

Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
Tahani Al-Manie
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
Sushant Mane
 
PYTHON NOTES
PYTHON NOTESPYTHON NOTES
PYTHON NOTES
Ni
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
MansiSuthar3
 
Python second ppt
Python second pptPython second ppt
Python second ppt
RaginiJain21
 
Python for loop
Python for loopPython for loop
Python for loop
Aishwarya Deshmukh
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Python training
Python trainingPython training
Python training
Kunalchauhan76
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
Syed Farjad Zia Zaidi
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
Sumit Satam
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
Mr. Vikram Singh Slathia
 
Python Basics
Python BasicsPython Basics
Python Basics
primeteacher32
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
Nilimesh Halder
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
Praveen M Jigajinni
 
Python The basics
Python   The basicsPython   The basics
Python The basics
Bobby Murugesan
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
Praveen M Jigajinni
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutability
Mohd Sajjad
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
Rasan Samarasinghe
 

What's hot (20)

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
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
 
PYTHON NOTES
PYTHON NOTESPYTHON NOTES
PYTHON NOTES
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
 
Python second ppt
Python second pptPython second ppt
Python second ppt
 
Python for loop
Python for loopPython for loop
Python for loop
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Python training
Python trainingPython training
Python training
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
Basic Concepts in Python
Basic Concepts in PythonBasic Concepts in Python
Basic Concepts in Python
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
 
Python The basics
Python   The basicsPython   The basics
Python The basics
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Python-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutabilityPython-04| Fundamental data types vs immutability
Python-04| Fundamental data types vs immutability
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 

Similar to Introduction to Python Part-1

Python Decision Making And Loops.pdf
Python Decision Making And Loops.pdfPython Decision Making And Loops.pdf
Python Decision Making And Loops.pdf
NehaSpillai1
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
ParrotAI
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
malekaanjum1
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
AnirudhaGaikwad4
 
Python
PythonPython
Python
Aashish Jain
 
GE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdfGE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdf
Asst.prof M.Gokilavani
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
RojaPriya
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
kavinilavuG
 
Review Python
Review PythonReview Python
Review Python
ManishTiwari326
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
shetoooelshitany74
 
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
notwa dfdfvs gf fdgfgh  s thgfgh frg regggnotwa dfdfvs gf fdgfgh  s thgfgh frg reggg
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
Godwin585235
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
Prakash Jayaraman
 
Unit -1 CAP.pptx
Unit -1 CAP.pptxUnit -1 CAP.pptx
Unit -1 CAP.pptx
malekaanjum1
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.ppt
jaba kumar
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
samiwaris2
 
Python by Rj
Python by RjPython by Rj
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
TKSanthoshRao
 
Basic of Python- Hands on Session
Basic of Python- Hands on SessionBasic of Python- Hands on Session
Basic of Python- Hands on Session
Dharmesh Tank
 
Help with Pyhon Programming Homework
Help with Pyhon Programming HomeworkHelp with Pyhon Programming Homework
Help with Pyhon Programming Homework
Helpmeinhomework
 

Similar to Introduction to Python Part-1 (20)

Python Decision Making And Loops.pdf
Python Decision Making And Loops.pdfPython Decision Making And Loops.pdf
Python Decision Making And Loops.pdf
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
 
Unit - 2 CAP.pptx
Unit - 2 CAP.pptxUnit - 2 CAP.pptx
Unit - 2 CAP.pptx
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
 
Python
PythonPython
Python
 
GE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdfGE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdf
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Review Python
Review PythonReview Python
Review Python
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdfPy-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
 
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
notwa dfdfvs gf fdgfgh  s thgfgh frg regggnotwa dfdfvs gf fdgfgh  s thgfgh frg reggg
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
Unit -1 CAP.pptx
Unit -1 CAP.pptxUnit -1 CAP.pptx
Unit -1 CAP.pptx
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.ppt
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
INTERNSHIP REPORT.docx
 INTERNSHIP REPORT.docx INTERNSHIP REPORT.docx
INTERNSHIP REPORT.docx
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Basic of Python- Hands on Session
Basic of Python- Hands on SessionBasic of Python- Hands on Session
Basic of Python- Hands on Session
 
Help with Pyhon Programming Homework
Help with Pyhon Programming HomeworkHelp with Pyhon Programming Homework
Help with Pyhon Programming Homework
 

More from Devashish Kumar

Python: Data Visualisation
Python: Data  VisualisationPython: Data  Visualisation
Python: Data Visualisation
Devashish Kumar
 
Pandas csv
Pandas csvPandas csv
Pandas csv
Devashish Kumar
 
Data Analysis packages
Data Analysis packagesData Analysis packages
Data Analysis packages
Devashish Kumar
 
Data Analysis in Python-NumPy
Data Analysis in Python-NumPyData Analysis in Python-NumPy
Data Analysis in Python-NumPy
Devashish Kumar
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
Devashish Kumar
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
Devashish Kumar
 
Cloud Computing Introductory-1
Cloud Computing Introductory-1Cloud Computing Introductory-1
Cloud Computing Introductory-1
Devashish Kumar
 

More from Devashish Kumar (7)

Python: Data Visualisation
Python: Data  VisualisationPython: Data  Visualisation
Python: Data Visualisation
 
Pandas csv
Pandas csvPandas csv
Pandas csv
 
Data Analysis packages
Data Analysis packagesData Analysis packages
Data Analysis packages
 
Data Analysis in Python-NumPy
Data Analysis in Python-NumPyData Analysis in Python-NumPy
Data Analysis in Python-NumPy
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Cloud Computing Introductory-1
Cloud Computing Introductory-1Cloud Computing Introductory-1
Cloud Computing Introductory-1
 

Recently uploaded

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 

Recently uploaded (20)

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 

Introduction to Python Part-1

  • 1. One Day Workshop on Python Devashish Kumar Faculty-IT iNurture
  • 2.
  • 3. Programming Language  A programming language is a notation for writing programs.  A programming language is a computer language designed to communicate instructions to a machine, particularly a computer.  Programming languages can be used to create programs, to control the behaviour of a machine or to express algorithms.  Various programming languages are such as: c , c++ , R, java, C# , ruby , python etc.
  • 4. What is Python ? Python is a high level programming language which is: Interpreted Interactive Object-Oriented Dynamic programming language Open source model
  • 5. WHY PYTHON ? Python is nowadays widely used as an programming language. It has :-  Simple syntax  One-Line command  English like commands(easily readable)  Dynamically Typed  Easily Indentable  Intuitive data structures like tuples, sets, dictionaries,strings,lists etc
  • 6. Applications of Python language Python language used in: – Web Development – Database programming – Game Development – Scientific Computing – Web Framework – Molecular Biology
  • 7. WHY 2.7 RELEASE AFTER 3.X ? • Version 2.X has an awful quantity of useful libraries that haven’t been ported to 3.X version. • Current Linux distributions and Macs are still using 2.x as default. Some are phasing out Python 2 as preinstalled default. • Python 3 already broadly supports creating GUI applications, with Tkinter ,etc. in the standard library. • Python 2.7 provides a stable and a supported base platform for production system that have not yet been ported to Python 3.
  • 8.  In Python 2.X, range() and xrange() function is used for iterating and range() function behaves as it is a list.  In Python 2.X, data type returned is in int,char etc.  In python 2.X, no TypeError is raised if we try to compare unorderable type.  Handling exception: In python 2.X, for handling exception in the syntax we use comma instead of ‘as’.  In python 3.X, xrange() function is not used, it gives name error and range doesnot behave as a list.  In python 3.x, data type returned is in class.  In python 3.X, TypeError is raised as warning if we try to compare unorderable type.  In python 3.X, for handling exception in the syntax we use ‘as’ keyword.
  • 9.  Packages like NumPy and SciPy, Django,Flask,CherryPy and Pyramid is not included in python 2.X.  Integer Division: Python 2.X treats numbers that you type without any digit after the decimal point as integers,which can lead to some unexpected results.  Raising Exceptions:  List comprehension loop variables:  Packages like NumPy and SciPy, Django,Flask,CherryPy and Pyramid is ported to python 3.X .  Python 3.X evaluates “3/2” as 1.5 by default,which is more intuitive for programmer.  Raising exceptions:  List comprehension loop variables:
  • 10.  Future_module: this module is used to help in migration.  .Next() function: Python 2.X supports .next() function.  Output:  Python 2.x has two integer types: int and long  Future Module:  .Next() function: Python 3.X doesn’t support “.next()” function.  In Python 3.x, no long integer type is specified.
  • 12. PYTHON VARIABLES  A variable is a location in memory used to store some data.  They are given unique names to differentiate between different memory locations.  Don't need to declare a variable before using it.  In Python, simply assign a value to a variable and it will exist. Don’t declare the type of the variable.  VARIABLE ASSIGNMENT: We use the assignment operator (=) to assign values to a variable.  MULTIPLE ASSIGNMENT: In Python, multiple assignments can be made in a single statement.  We can assign the same value to multiple variables at once. Assignment operator
  • 13. NUMBERS  Number data types store numeric values.  They are immutable data types.  Number objects are created when you assign a value to them.  We can delete the reference to a number object by using the del statement.  Syntax: del var1[,var2[,var3[...., varN]]]]  We can delete a single object or multiple objects by using the del statement.
  • 14. NUMBERS  Integer numbers: Integers can be of any length, it is only limited by the memory available. They are positive or negative whole numbers with no decimal point.  Floating point number : It is accurate up to 15 decimal places.  Complex numbers : These are written in the form, x + yj, where x is the real part and y is the imaginary part.  Examples: Integer no: Floating point no: Complex number
  • 15. EXAMPLES OF NUMBER  In interactive mode, the last printed expression is assigned to the variable _  Example:  Division (/) always returns a float.  To get an integer result, use floor division (//)  To calculate the remainder you can use %:
  • 16. NUMBERS  Abs(): returns the absolute value of x i.e. the positive distance between x and zero.  Ceil() : returns the ceiling value of x i.e. the smallest integer not less than x.  EXP(): returns exponential of x: (e power x).  Fabs(): returns the absolute value of x. fabs() is defined in math module and works only on float and integer number.
  • 17. NUMBERS • Floor(): returns the floor of x i.e. the largest integer not greater than x. • Log(): returns the natural logarithm of x. • Log10(): returns base-10 logarithm of x for x > 0. • Max(): returns the largest of its arguments • There are many more functions that perform mathematical operations on numbers.
  • 19. Control Flow And Loops Various control statements are:  if and else  Elif For Range While Break Continue
  • 20. IF AND ELSE STATEMENT • The syntax for if statement in python are: • For example: if (condition): #execution of an if statement statement1 statement2 else: #execution of an else statement statement1 statement2 • If we use else statement without using if statement then it will raise an error.
  • 21. Example of If And Else Output:
  • 22. Elif statement • Elif statement is similar to the else if statement used in c or c++. • Elif statement is a combination of else and if statement. • Syntax: if (condition): statement1 statement2 elif (condition): # elif is a combination of else if statement3 statement4 else: statement5 • There can be zero or more elif parts, and the else part is optional. The keyword ‘elif ‘ is short for ‘else if’, and is useful to avoid excessive indentation.
  • 23. Example of Elif statement Output:
  • 24. For Statement  The for statement in Python differs from in C or C++.  Python’s for statement iterates over the items of any sequence , in the order that they appear in the sequence.  Syntax: for i in m: // repeat body for each item in m
  • 25. Examples of For statement Output: Output Example 2:Example1:
  • 26. Range Function  Range function is used If we do not want to iterate over a sequence of numbers.  Range function produces the sequences of values ie i,i+1,……….j-1 if it range(i,j).  If range(i,j,k) then it increments by k that is i, i+k,……………………….,i+nk.  Sequence produced by a range is not a list, use list(range(..)) to get a list.  Why does range(i ,j) stops at j-1?  to make it easier to process lists  To iterate over the indices of a sequence, you can combine range() and len() as follows:
  • 27. Examples Of Range Function
  • 28. WHILE LOOP • While loop in Python is used to iterate over a block of code as long as the test expression(condition) is true. • Syntax: while condition: statement(s) //repeat body till condition becomes false • Loop might not ever run: When the condition is tested and the result is false then the loop body will be skipped and the first statement after the while loop is executed. • Example: output:
  • 29. Break Statement  The break statement in python terminates the current loop and resumes execution at the next statement , just like break statement in c.  The break statement can be used in both for and while loops. Output:
  • 30. Continue Statement • Continue statement in Python returns the control to the beginning of the while or for loop. The continue statement rejects all the remaining statement in the current iteration of the loop and moves the control back to the top of the loop. Output:
  • 31. Pass Statement  The pass statement is used in Python when statement is required but you do not want any command or code to execute.  The pass statement is a null operation means nothing happens when it executes. Suppose we have a loop or function that is not implemented yet , but we want to implement it in future. They cannot have an empty body.  Pass statement is there to create minimal classes.  It is useful when you have created a code block but it is no longer required. Comment statement is ignored by interpreter entirely and pass is not ignored.  Example: output