SlideShare a Scribd company logo
Content
1. What is Python
2. Python Release
3. Application of Python
4. Features of Python
5. Tokens in Python
6. Comments in Python
7. Variables
1. What is Python?
Python is an interpreted, object-oriented, high-level
programming language for general-purpose(use for multi purpose
e.g. web app, desktop app, data science etc) programming. Created by
Guido van Rossum and first released in 1991.
Python is a cross-platform programming language,
meaning, it runs on multiple platforms like Windows, Mac
OS X, Linux, Unix.
Rossum was fan of a comedy series from late seventies.
The name "Python" was adopted from the same series
"Monty Python's Flying Circus".
2. Major release date of Python
Version Release date
Python 1.0 (Version) January 1994
Python 1.6 5 Sept 2000
Python 2.0 16 Oct 2000
Python 2.7 4 Jul 2010
Python 3.0 3 Dec 2008
Python 3.6.0 23 Dec 2016
Python 3.6.5 (Latest) 28 Mar 2018
3. Application of Python
Where we can use Python
 Desktop Application
 Web and Internet Application
 Database Application
 Networking Application
 Games
 Data Analysis (data science)
 Machine Learning
 Artificial Application
4. Features Of Python
 Simple and easy to learn
 It's much easier to read and write Python
programs compared to other languages like: C++,
Java, C#.
 Free and Open source
 You can freely use and distribute Python, even for
commercial use.
 Also you can able to see the source code and
even can make changes to the code.
Cont..
 High level programming language
 We are never required to worry about low level
activities like memory management, securities etc.
 Programming friendly language
 Platform Independent
• On any machine like widows, Linux or Mac we
are able to run the code anywhere
• We write code only once and can run on different
machine
• Write once and run anywhere (WORA)
Cont....
 Portability
 You can move Python programs from one
platform to another, and run it without any
changes.
Python
Program
written in
windows
Linux, MAC
etc
Portable
Think it as a mobile number portability, Airtel can be transferred to idea
operator without changing the phone number
Cont...
 Dynamically typed
 In python, there is no need to declare data type for
the variables, it internally create types, referring to the
values.
 C, C++ or Java are statically typed
 x = 10, python automatically assigns x as int
x = 10.5, python now accept it as float
x = True (now, type = Boolean)
so the variables are dynamically typed. In C or C++ or even in java if you
declare x as int then you cannot use it for a float value, if you do they
will through error
Cont....
 Object-Oriented
Python is object oriented as it supports
Class, Object, Data hiding, Data Encapsulated,
Polymorphism etc. It is also an procedural oriented as
we can make the program without classes if we don’t
need security.
C is procedural objected language but not
object-oriented
Java is Object-Oriented not procedural
because you can't code anything in Java without
declaring classes and objects.
Cont....
 Interpreted Language
when you run Python code, it automatically
converts your code to the language your computer
understands.You don't need to worry about any
lower-level operations.
It scans code line by line.
 Python is Extensible
You can easily combine pieces of C/C++ or other
languages with Python code.
We can improve the performance of the
application using this feature
5. Tokens
Individual words and punctuation marks are
called tokens or lexical units.
Python has following tokens:
5.1. Keywords
5.2. Identifiers (Name)
5.3. Literals
5.4. Operators
5.5. Punctuators
5.1. Keywords
 Keywords are the reserved words and convey
special meaning. Has 33 keywords
False assert del for in or while
True break elif from is pass with
None class else global lambda raise yield
and continue except if nonlocal return
as finally import not def try
5.2. Identifiers
 An identifier are the names to different part of the program
e.g. Variables, objects, classes, functions, list, dictionaries etc.
 Allowed symbols are (a to z), (A to Z), (0 to 9) and (_).
 Should not start with digits. (can be start by a letter or
underscore(_)).
 The digits ( 0 through 9) can be part of identifier except for
the first character
 Case-sensitive.
 Cannot use reserved words as identifiers.
 Identifiers are unlimited in length (no length limit).
 If any identifier starts with _ (e.g., _x) then this variable is
treated as private. If uses two (e.g., __x) then it is strongly
private
Cont...
 Valid identifier  Invalid Identifier
Myfile
myFile
_xy
_3
a2n56y
_chk
_3abc
My.file
2abc
$ab12
Data-rec
Break
a@abc
for
5.3. Literals/Values
Literals often referred to as constant-values
that have a fixed value.
Python allows several kinds of literals:
5.3.a. String literals
5.3.b. Numeric literals
5.3.c. Boolean literals
5.3.d. Special literal None
5.3.a. String literals
 String literal can be form by enclosing
text in single or double quotes
 E.g., ‘Arun’ ‘HelloWorld’ “112”
 Python allows two string types:
✓ Single line string
✓ Multi line string
Single line string Multi line string
 Terminate in one line
 E.g.,Text = ‘Hello’
 E.g.,Text = “Hello”
 Text = ‘hello
world’
Python will show you an
error
 Text spread across multiple
lines as one single string
 Can be created in two ways
either by triple quotation
mark (‘’’) or by backslash()
 E.g.,Text = ‘hello 
world’
Text = ‘’’this
Is another
multiline string’’’
Cont...
Multiline string literals can be created by two ways
either by triple quote(‘’’) or by backslash()
But the difference
This is only for the sake of
better readability in the
program. It doesn’t gives the
new line in the output, usually
uses in shell.
This is used when you have to
print multiple lines in output.
Gives output same as you write.
5.3.b. Numeric Literals
There are 3 numerical types
Int :- also called integers, are positive or negative whole
numbers with no decimal point (E.g., 2, -6). Int can be
represented in 4 ways and will be discuss in next slide.
Float :- represent real numbers and written with a
decimal point. (e.g., 17.5, -13.0)
Complex :- are of the form a + ib, where a and b are
floats and i =
One more numerical literal is Long which is used in 2.x but removed from
Python 3.
Cont...
int values further represented in 4 ways:
 Decimal values(Base 10): sequence of digits (0 to 9)
unless start with zero(e.g., 12, -7).
 Binary values(Base 2): sequence of only 1 and 0 , starts
with 0B or 0b (e.g., 0b1010).
 Octal values(Base 8): sequence of digits(0 to 7) starts
with 0O or 0o(zero-O) (e.g., 0o241)
 Hexadecimal values(Base 16):sequence of(0 to 9, a to
f,A to F) preceded by 0x or 0X(e.g., oxFace, oxBk9)
In Python 2.x, octal value can also be represented as preceded by only 0 or 0o
or 0O but preceding by only 0 will through an error in 3.x
5.3.c. Boolean Literal
A Boolean literal can either have True or
False.
5.3.d. Special literal None
The None literal in python means
“There’s nothing”
5.4. Operators
An Operator performs operation on data.
There are 7 operator in python
✓ Arithmetic operator
✓ Assignment operator
✓ Relational operator
✓ Logical operator
✓ Bitwise operator
✓ Membership operator
✓ Identity operator
We will learn more about operators in python in our next PPT
5.5. Punctuators
Punctuators are symbol/character that has
syntactic and semantic meaning to the compiler,
they are used in programming language to
organize sentence structure.
Most common punctuators in Python are:
‘ “ #  ( ) [ ] { } @ , : . = ; `
6. Comments in Python
Comments are additional readable information, which is
read by the programmers but ignored by Python
interpreter.
A single line comment can be inserted with #.
A multi line comment can be inserted with triple-
apostrophe(‘’’) or triple quotes(“””)
‘’’Multiline comments are useful for detailed additional information related to
the program.This type of multiline comment also known as docstring.
7. Variables
 Variable is a named location used to store data
in the memory
OR
Reserved memory location to store values.
 Each variable must have a unique name called
identifier. (discussed identifier in 5.2)
 Creating variable
MyName = “sajjad’
Cont...
 Variable is not created until some value is assigned to it.
 We can use the del statement to remove a variable
#Variable b is not assigned
Cont...
 In Python, variables do not need declaration to
reserve memory space this makes it dynamically
typed.
 “Variable declaration“ happens automatically
when we assign a value to a variable.
 Python create a variable of the type similar to
the type of value assigned.
E.g., age = 20
age is a numeric variable
Cont...
 In Python, program access data values through
references.
 A reference is a name that refers to the specific
location in memory of a value (object).
 Python internally create labels referring to
these values
Name
Age
 ‘sajjad’
 22
Cont...
5
1837884240
a
b
4
1837884224
Id is built in function use to get the address of an identifier.
Cont....
Multiple Assignments
 Assign same value to multiple variable
a = b = c = d = 10
 Assign multiple values to multiple variable
p, q, r = 5, 10, 7.5
 Expression separated with commas are evaluated
from left to right
E.g., x, x = 10, 12
print(x) #12
Cont...
EXAMPLE 1
EXAMPLE 2
Cont....
ProgramOutput
Cont....
Multiple assignment makes swapping easy
Cont...
DynamicType
For instance,
x = 10 #variable x is of int type
if you assign value of some other type to x, python will
not complain(no error)
x = 10
print(x)
x = ‘hello’ x
print(x)
Output will be:
10
hello
Int: 10
String: hello
X doesn’t have type but value it points to have type. So we can make variable
point to a value of different type.This is called dynamicTyping.
Cont....
To determine the type of a variable, we can use type() as:
type(<variable name>)

More Related Content

PPTX
Python 3 Programming Language
PDF
Python programming : List and tuples
PPT
Parts of a Computer
PPTX
Notion of an algorithm
PDF
Python final ppt
PDF
Zero to Hero - Introduction to Python3
PPTX
Python Data-Types
PPTX
Introduction to python for Beginners
Python 3 Programming Language
Python programming : List and tuples
Parts of a Computer
Notion of an algorithm
Python final ppt
Zero to Hero - Introduction to Python3
Python Data-Types
Introduction to python for Beginners

What's hot (20)

PPTX
Python
PPT
Python Programming Language
PPTX
Python presentation by Monu Sharma
PPTX
Python - An Introduction
PPT
Python Programming ppt
PPTX
Introduction to the basics of Python programming (part 1)
PPT
Intro to Python
PPTX
Operators in Python
PPTX
Functions in C
PPTX
Python programming | Fundamentals of Python programming
PDF
Introduction to Python
PPTX
Basic Python Programming: Part 01 and Part 02
PPTX
Python programming introduction
PPT
Variables in C Programming
PPTX
Data Type in C Programming
PDF
Introduction to python programming
PPT
programming with python ppt
PPTX
Python Functions
PPTX
Python | What is Python | History of Python | Python Tutorial
Python
Python Programming Language
Python presentation by Monu Sharma
Python - An Introduction
Python Programming ppt
Introduction to the basics of Python programming (part 1)
Intro to Python
Operators in Python
Functions in C
Python programming | Fundamentals of Python programming
Introduction to Python
Basic Python Programming: Part 01 and Part 02
Python programming introduction
Variables in C Programming
Data Type in C Programming
Introduction to python programming
programming with python ppt
Python Functions
Python | What is Python | History of Python | Python Tutorial
Ad

Similar to Python-01| Fundamentals (20)

PPTX
python ppt | Python Course In Ghaziabad | Scode Network Institute
PPTX
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
PPTX
Introduction on basic python and it's application
PPTX
Python Introduction
PDF
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
PPTX
Python (Data Analysis) cleaning and visualize
PPTX
UNIT 1 PYTHON introduction and basic level
PPTX
python questionsfor class 8 students and
PDF
PPTX
python
PPTX
Introduction to Python for Data Science and Machine Learning
PPTX
Unit -1 CAP.pptx
PPTX
Python introduction towards data science
PDF
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PPTX
Chapter 1-Introduction and syntax of python programming.pptx
PPTX
Welcome to python workshop
PPT
Python - Module 1.ppt
PDF
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
PPTX
Python basics
PPTX
Introduction to learn and Python Interpreter
python ppt | Python Course In Ghaziabad | Scode Network Institute
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
Introduction on basic python and it's application
Python Introduction
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
Python (Data Analysis) cleaning and visualize
UNIT 1 PYTHON introduction and basic level
python questionsfor class 8 students and
python
Introduction to Python for Data Science and Machine Learning
Unit -1 CAP.pptx
Python introduction towards data science
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
Chapter 1-Introduction and syntax of python programming.pptx
Welcome to python workshop
Python - Module 1.ppt
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
Python basics
Introduction to learn and Python Interpreter
Ad

More from Mohd Sajjad (6)

PPTX
Python-04| Fundamental data types vs immutability
PDF
Python-03| Data types
PDF
Python-02| Input, Output & Import
PPTX
Python-00 | Introduction and installing
PPTX
Secure your folder with password/without any software
PPTX
SNMP Protocol
Python-04| Fundamental data types vs immutability
Python-03| Data types
Python-02| Input, Output & Import
Python-00 | Introduction and installing
Secure your folder with password/without any software
SNMP Protocol

Recently uploaded (20)

PPTX
“Next-Gen AI: Trends Reshaping Our World”
PPT
Chapter 6 Design in software Engineeing.ppt
PPTX
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
PPTX
OOP with Java - Java Introduction (Basics)
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
PPTX
Road Safety tips for School Kids by a k maurya.pptx
PPTX
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
PDF
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
PPT
Drone Technology Electronics components_1
PPTX
436813905-LNG-Process-Overview-Short.pptx
PDF
International Journal of Information Technology Convergence and Services (IJI...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
AgentX UiPath Community Webinar series - Delhi
PDF
Queuing formulas to evaluate throughputs and servers
PPTX
Internship_Presentation_Final engineering.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Top 10 read articles In Managing Information Technology.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
“Next-Gen AI: Trends Reshaping Our World”
Chapter 6 Design in software Engineeing.ppt
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
OOP with Java - Java Introduction (Basics)
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
Road Safety tips for School Kids by a k maurya.pptx
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
Drone Technology Electronics components_1
436813905-LNG-Process-Overview-Short.pptx
International Journal of Information Technology Convergence and Services (IJI...
Lesson 3_Tessellation.pptx finite Mathematics
AgentX UiPath Community Webinar series - Delhi
Queuing formulas to evaluate throughputs and servers
Internship_Presentation_Final engineering.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Top 10 read articles In Managing Information Technology.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx

Python-01| Fundamentals

  • 1. Content 1. What is Python 2. Python Release 3. Application of Python 4. Features of Python 5. Tokens in Python 6. Comments in Python 7. Variables
  • 2. 1. What is Python? Python is an interpreted, object-oriented, high-level programming language for general-purpose(use for multi purpose e.g. web app, desktop app, data science etc) programming. Created by Guido van Rossum and first released in 1991. Python is a cross-platform programming language, meaning, it runs on multiple platforms like Windows, Mac OS X, Linux, Unix. Rossum was fan of a comedy series from late seventies. The name "Python" was adopted from the same series "Monty Python's Flying Circus".
  • 3. 2. Major release date of Python Version Release date Python 1.0 (Version) January 1994 Python 1.6 5 Sept 2000 Python 2.0 16 Oct 2000 Python 2.7 4 Jul 2010 Python 3.0 3 Dec 2008 Python 3.6.0 23 Dec 2016 Python 3.6.5 (Latest) 28 Mar 2018
  • 4. 3. Application of Python Where we can use Python  Desktop Application  Web and Internet Application  Database Application  Networking Application  Games  Data Analysis (data science)  Machine Learning  Artificial Application
  • 5. 4. Features Of Python  Simple and easy to learn  It's much easier to read and write Python programs compared to other languages like: C++, Java, C#.  Free and Open source  You can freely use and distribute Python, even for commercial use.  Also you can able to see the source code and even can make changes to the code.
  • 6. Cont..  High level programming language  We are never required to worry about low level activities like memory management, securities etc.  Programming friendly language  Platform Independent • On any machine like widows, Linux or Mac we are able to run the code anywhere • We write code only once and can run on different machine • Write once and run anywhere (WORA)
  • 7. Cont....  Portability  You can move Python programs from one platform to another, and run it without any changes. Python Program written in windows Linux, MAC etc Portable Think it as a mobile number portability, Airtel can be transferred to idea operator without changing the phone number
  • 8. Cont...  Dynamically typed  In python, there is no need to declare data type for the variables, it internally create types, referring to the values.  C, C++ or Java are statically typed  x = 10, python automatically assigns x as int x = 10.5, python now accept it as float x = True (now, type = Boolean) so the variables are dynamically typed. In C or C++ or even in java if you declare x as int then you cannot use it for a float value, if you do they will through error
  • 9. Cont....  Object-Oriented Python is object oriented as it supports Class, Object, Data hiding, Data Encapsulated, Polymorphism etc. It is also an procedural oriented as we can make the program without classes if we don’t need security. C is procedural objected language but not object-oriented Java is Object-Oriented not procedural because you can't code anything in Java without declaring classes and objects.
  • 10. Cont....  Interpreted Language when you run Python code, it automatically converts your code to the language your computer understands.You don't need to worry about any lower-level operations. It scans code line by line.  Python is Extensible You can easily combine pieces of C/C++ or other languages with Python code. We can improve the performance of the application using this feature
  • 11. 5. Tokens Individual words and punctuation marks are called tokens or lexical units. Python has following tokens: 5.1. Keywords 5.2. Identifiers (Name) 5.3. Literals 5.4. Operators 5.5. Punctuators
  • 12. 5.1. Keywords  Keywords are the reserved words and convey special meaning. Has 33 keywords False assert del for in or while True break elif from is pass with None class else global lambda raise yield and continue except if nonlocal return as finally import not def try
  • 13. 5.2. Identifiers  An identifier are the names to different part of the program e.g. Variables, objects, classes, functions, list, dictionaries etc.  Allowed symbols are (a to z), (A to Z), (0 to 9) and (_).  Should not start with digits. (can be start by a letter or underscore(_)).  The digits ( 0 through 9) can be part of identifier except for the first character  Case-sensitive.  Cannot use reserved words as identifiers.  Identifiers are unlimited in length (no length limit).  If any identifier starts with _ (e.g., _x) then this variable is treated as private. If uses two (e.g., __x) then it is strongly private
  • 14. Cont...  Valid identifier  Invalid Identifier Myfile myFile _xy _3 a2n56y _chk _3abc My.file 2abc $ab12 Data-rec Break a@abc for
  • 15. 5.3. Literals/Values Literals often referred to as constant-values that have a fixed value. Python allows several kinds of literals: 5.3.a. String literals 5.3.b. Numeric literals 5.3.c. Boolean literals 5.3.d. Special literal None
  • 16. 5.3.a. String literals  String literal can be form by enclosing text in single or double quotes  E.g., ‘Arun’ ‘HelloWorld’ “112”  Python allows two string types: ✓ Single line string ✓ Multi line string
  • 17. Single line string Multi line string  Terminate in one line  E.g.,Text = ‘Hello’  E.g.,Text = “Hello”  Text = ‘hello world’ Python will show you an error  Text spread across multiple lines as one single string  Can be created in two ways either by triple quotation mark (‘’’) or by backslash()  E.g.,Text = ‘hello world’ Text = ‘’’this Is another multiline string’’’
  • 18. Cont... Multiline string literals can be created by two ways either by triple quote(‘’’) or by backslash() But the difference This is only for the sake of better readability in the program. It doesn’t gives the new line in the output, usually uses in shell. This is used when you have to print multiple lines in output. Gives output same as you write.
  • 19. 5.3.b. Numeric Literals There are 3 numerical types Int :- also called integers, are positive or negative whole numbers with no decimal point (E.g., 2, -6). Int can be represented in 4 ways and will be discuss in next slide. Float :- represent real numbers and written with a decimal point. (e.g., 17.5, -13.0) Complex :- are of the form a + ib, where a and b are floats and i = One more numerical literal is Long which is used in 2.x but removed from Python 3.
  • 20. Cont... int values further represented in 4 ways:  Decimal values(Base 10): sequence of digits (0 to 9) unless start with zero(e.g., 12, -7).  Binary values(Base 2): sequence of only 1 and 0 , starts with 0B or 0b (e.g., 0b1010).  Octal values(Base 8): sequence of digits(0 to 7) starts with 0O or 0o(zero-O) (e.g., 0o241)  Hexadecimal values(Base 16):sequence of(0 to 9, a to f,A to F) preceded by 0x or 0X(e.g., oxFace, oxBk9) In Python 2.x, octal value can also be represented as preceded by only 0 or 0o or 0O but preceding by only 0 will through an error in 3.x
  • 21. 5.3.c. Boolean Literal A Boolean literal can either have True or False. 5.3.d. Special literal None The None literal in python means “There’s nothing”
  • 22. 5.4. Operators An Operator performs operation on data. There are 7 operator in python ✓ Arithmetic operator ✓ Assignment operator ✓ Relational operator ✓ Logical operator ✓ Bitwise operator ✓ Membership operator ✓ Identity operator We will learn more about operators in python in our next PPT
  • 23. 5.5. Punctuators Punctuators are symbol/character that has syntactic and semantic meaning to the compiler, they are used in programming language to organize sentence structure. Most common punctuators in Python are: ‘ “ # ( ) [ ] { } @ , : . = ; `
  • 24. 6. Comments in Python Comments are additional readable information, which is read by the programmers but ignored by Python interpreter. A single line comment can be inserted with #. A multi line comment can be inserted with triple- apostrophe(‘’’) or triple quotes(“””) ‘’’Multiline comments are useful for detailed additional information related to the program.This type of multiline comment also known as docstring.
  • 25. 7. Variables  Variable is a named location used to store data in the memory OR Reserved memory location to store values.  Each variable must have a unique name called identifier. (discussed identifier in 5.2)  Creating variable MyName = “sajjad’
  • 26. Cont...  Variable is not created until some value is assigned to it.  We can use the del statement to remove a variable #Variable b is not assigned
  • 27. Cont...  In Python, variables do not need declaration to reserve memory space this makes it dynamically typed.  “Variable declaration“ happens automatically when we assign a value to a variable.  Python create a variable of the type similar to the type of value assigned. E.g., age = 20 age is a numeric variable
  • 28. Cont...  In Python, program access data values through references.  A reference is a name that refers to the specific location in memory of a value (object).  Python internally create labels referring to these values Name Age  ‘sajjad’  22
  • 29. Cont... 5 1837884240 a b 4 1837884224 Id is built in function use to get the address of an identifier.
  • 30. Cont.... Multiple Assignments  Assign same value to multiple variable a = b = c = d = 10  Assign multiple values to multiple variable p, q, r = 5, 10, 7.5  Expression separated with commas are evaluated from left to right E.g., x, x = 10, 12 print(x) #12
  • 34. Cont... DynamicType For instance, x = 10 #variable x is of int type if you assign value of some other type to x, python will not complain(no error) x = 10 print(x) x = ‘hello’ x print(x) Output will be: 10 hello Int: 10 String: hello X doesn’t have type but value it points to have type. So we can make variable point to a value of different type.This is called dynamicTyping.
  • 35. Cont.... To determine the type of a variable, we can use type() as: type(<variable name>)