SlideShare a Scribd company logo
4/29/2020
athithanvijay@jayamnetworks.com1
Topics
What is programming language?
Simple program in Python
Python – Data types
Python – Comments
Python
We use natural languages to communicate among
us.
Mathematicians express in terms of equations.
Chemists use formulas to communicate.
How about software developers?
They use programming languages(Python, Java,
.NET, C, C++, etc ) to communicate with
computers.
Python
How to master a programming language?
Three steps
1. Learn elements in a language as per language
specification - language tokens ( A-Z,0-9 etc)
2. Learn how to form statements rightly as per
language specification – Syntax ( ‘He is tall’ – right,
‘He are tall’ – wrong syntax)
3. Learn to write right statements to carry out
given task as per user/customer requirements-
semantics – I can and can I? use same words but
provides different meaning.
Python
Python Language elements
Token Description Examples
Literals/
values/
constant
Value that remains same everywhere in the
program.
Values belong to different data types
Number. Numeric value 10
doesn’t change. Hello is a text
value which consists of
characters.
keywords Words used by Python to structure the program
and carries specific meaning.
if, continue
Identifiers
(variables/
functions)
Variable name given to store value that might
change
Function name denotes set of statements in the
program
Temperature=35
Temperature=40
Temperature value changes
Operators Symbols to perform operations ( arithmetic,
logical, relational etc)
+, -, *, / , and, or, =>, <
Expressions Combination of values, operators and variable
to produce a value
X=4+5
Statements Instruction given to computer to perform an
action
For, if
comments Add hints to program and should be ignored
during execution
# hello world program
Let us write a shortest Python program to print the
word hello in screen.
Create a textfile in notepad or other text editor and
type the following line
print(“hello”)
then save the file in the following format.
Filename.py (eg. hello.py)
Then run the python program as below
python hello.py
It will print the text hello in the screen.
Is not simple to create and run a python program?
Python Language elements
Type python and file name in the command line
python hello.py
How to run Python program
# is used to mark comment.
Text that follows # will not be executed.
Used to write hints for future use.
Python comments
Let us put the text inside two double quotes next to
print inside brackets
print(“hello”)
In case of numbers, the same print will work
print(10). Note that there is no double quotes in
case of numbers.
Python – Printing characters(text) and numbers
print(10) is different from print(“ten”)
10 is a number. “ten” is set of
characters(text/string/chars).
We can perform different operations on
number.(Eg. 10 + 20, 10 -5, 10*5 etc)
Whereas chars support different set of operations
(Eg. Length of a given word, concatenating two
words, occurrence particular letter in a word etc)
Python supports specific set of operations on
different type of values.
Python – values
Let us try Python in shell
Type Python in command line
type is a function that returns data type for given value.
type(10) returns int and type(“10”) returns str.
Print is a function. Let us see functions usage later.
Python – Data types
Values, values attributes and operations form data
types.
Eg integer can represent numbers using digits.
Can do +,-,* etc.
Python – Data types
Numbers
• Integer
• Float
• Boolean
• Complex
Number
Mappings
• Dictionary
Sequence
• String
• List
• Tuple
• Bytes
Set types
• Sets
Python Data Types
Keywords must not be used as identifier/variables
name.
Source:https://docs.python.org
Python – Keywords
Want to store some value during program execution in computer
memory and refer that value using a name as we wish – identifier
Variable is one type of identifier.
There is no need to mention datatype name while declaring variables in
python. In other languages we need to declare variables with data type.
marks= 80 // marks is an integer variable
Name = “vijay” // Name is a string variable
Variables promotes readability
print(marks) is better than print(80)
Variables promotes reusability
Python – Identifier
Want to store some value during program execution in computer
memory and refer that value using a name as we wish – identifier
Variable is one type of identifier.
Values can be stored in variables for future use.
marks= 80 // marks is an integer variable
Name = “vijay” // Name is a string variable
print(marks)
print(Name)
Variables promotes readability in the program.
print(marks) is better than print(80)
Variables promote reusability
Total=mark1 + mark2
Value of mark1 and mark2 are used to assign new value for another
variable Total
Python – Identifier
Variables promote maintainability in the code.
print(3.14)
Print(3.14)
Print(3.14)
If you want to change 3.14 into 3.16 you need to change three lines
print(3.16)
print(3.16)
print(3.16)
Let us store 3.14 in a variable, then print three times
pivalue = 3.14
print(pivalue)
print(pivalue)
Print(pivalue)
Let us change pivalue= 3.16. This only change is enough to print 3.16
three times.
Python – Identifier
Rules for variablenames
There is no need to mention datatype name while declaring variables in
python. In other languages we need to declare variables with data type.
• Must start with a letteror the underscorecharacter
• Variable names cannot start with a number
• A variable name can only contain alpha-numericcharacters and underscores(A-z,
0-9, and _ )
• Variable names are case-sensitive (name, Name and NAME are three different
variables)
Valid variable names
num, total, total6
Invalid variable names
6total - starts with number
Total* - contains special char
global – it’s a Python key word
Python – Identifier
Next topic : Operators
Python – Identifier
Python Language elements
Token Description Examples
Literals/
values/
constant
Value that remains same everywhere in the
program.
Values belong to different data types
Number. Numeric value 10
doesn’t change. Hello is a text
value which consists of
characters.
keywords Words used by Python to structure the program
and carries specific meaning.
if, continue
Identifiers
(variables/
functions)
Variable name given to store value that might
change
Function name denotes set of statements in the
program
Temperature=35
Temperature=40
Temperature value changes
Operators Symbols to perform operations ( arithmetic,
logical, relational etc)
+, -, *, / , and, or, =>, <
Expressions Combination of values, operators and variable
to produce a value
X=4+5
Statements Instruction given to computer to perform an
action
For, if
comments Add hints to program and should be ignored
during execution
# hello world program
4/29/2020
Vijay
athithanvijay@jayamnetworks.com
Please visit
https://www.jayamnetworks.com
for more learning contents
20

More Related Content

PDF
Data types in python
PPTX
Introduction to Python programming Language
PPTX
Python second ppt
PPTX
Presentation on python data type
PPTX
Chapter 9 python fundamentals
PDF
Python-01| Fundamentals
PDF
Numeric Data types in Python
PPTX
Python Data-Types
Data types in python
Introduction to Python programming Language
Python second ppt
Presentation on python data type
Chapter 9 python fundamentals
Python-01| Fundamentals
Numeric Data types in Python
Python Data-Types

What's hot (19)

PPTX
Python 3 Programming Language
PPTX
11 Unit 1 Chapter 02 Python Fundamentals
PDF
Introduction To Programming with Python
PDF
Data handling CBSE PYTHON CLASS 11
PPTX
Introduction To Programming with Python-3
PPTX
Python-04| Fundamental data types vs immutability
PPTX
Values and Data types in python
PDF
Python revision tour II
PPTX
Python Tutorial Part 1
PPT
Data Handling
PDF
+2 Computer Science - Volume II Notes
PDF
Lesson 03 python statement, indentation and comments
PPTX
Chapter 10 data handling
PPTX
Lexical analyzer
PDF
Oop with c++ notes unit 01 introduction
PPTX
Full Python in 20 slides
PPTX
Regular Expressions
PPTX
Data types in python lecture (2)
PPTX
Python data type
Python 3 Programming Language
11 Unit 1 Chapter 02 Python Fundamentals
Introduction To Programming with Python
Data handling CBSE PYTHON CLASS 11
Introduction To Programming with Python-3
Python-04| Fundamental data types vs immutability
Values and Data types in python
Python revision tour II
Python Tutorial Part 1
Data Handling
+2 Computer Science - Volume II Notes
Lesson 03 python statement, indentation and comments
Chapter 10 data handling
Lexical analyzer
Oop with c++ notes unit 01 introduction
Full Python in 20 slides
Regular Expressions
Data types in python lecture (2)
Python data type
Ad

Similar to Python Data Types (20)

PPTX
python_class.pptx
PPTX
BASICS OF PYTHON usefull for the student who would like to learn on their own
PPTX
Python (Data Analysis) cleaning and visualize
PDF
python.pdf
PPTX
2. Getting Started with Python second lesson .pptx
PPTX
Python for beginner, learn python from scratch.pptx
PPTX
Python 01.pptx
PPTX
Fundamentals of Python Programming
PPTX
PROGRAMMING-QUARTER-2-PYTHON.pptxnsnsndn
PPTX
Python Programming for problem solving.pptx
PDF
Introduction to Python - Jouda M Qamar.pdf
PPTX
Python Basics
DOCX
A Introduction Book of python For Beginners.docx
PDF
Python Programming
PPTX
UNIT 1 .pptx
PDF
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PDF
Sessisgytcfgggggggggggggggggggggggggggggggg
PPTX
INTRODUCTION TO PYTHON.pptx
PPTX
lecture 2.pptx
PPTX
Chapter 1-Introduction and syntax of python programming.pptx
python_class.pptx
BASICS OF PYTHON usefull for the student who would like to learn on their own
Python (Data Analysis) cleaning and visualize
python.pdf
2. Getting Started with Python second lesson .pptx
Python for beginner, learn python from scratch.pptx
Python 01.pptx
Fundamentals of Python Programming
PROGRAMMING-QUARTER-2-PYTHON.pptxnsnsndn
Python Programming for problem solving.pptx
Introduction to Python - Jouda M Qamar.pdf
Python Basics
A Introduction Book of python For Beginners.docx
Python Programming
UNIT 1 .pptx
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
Sessisgytcfgggggggggggggggggggggggggggggggg
INTRODUCTION TO PYTHON.pptx
lecture 2.pptx
Chapter 1-Introduction and syntax of python programming.pptx
Ad

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Institutional Correction lecture only . . .
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Complications of Minimal Access Surgery at WLH
PDF
Insiders guide to clinical Medicine.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Structure & Organelles in detailed.
PPTX
Lesson notes of climatology university.
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Computing-Curriculum for Schools in Ghana
Institutional Correction lecture only . . .
O5-L3 Freight Transport Ops (International) V1.pdf
O7-L3 Supply Chain Operations - ICLT Program
VCE English Exam - Section C Student Revision Booklet
Complications of Minimal Access Surgery at WLH
Insiders guide to clinical Medicine.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Structure & Organelles in detailed.
Lesson notes of climatology university.
Sports Quiz easy sports quiz sports quiz
PPH.pptx obstetrics and gynecology in nursing
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Microbial diseases, their pathogenesis and prophylaxis

Python Data Types

  • 2. Topics What is programming language? Simple program in Python Python – Data types Python – Comments Python
  • 3. We use natural languages to communicate among us. Mathematicians express in terms of equations. Chemists use formulas to communicate. How about software developers? They use programming languages(Python, Java, .NET, C, C++, etc ) to communicate with computers. Python
  • 4. How to master a programming language? Three steps 1. Learn elements in a language as per language specification - language tokens ( A-Z,0-9 etc) 2. Learn how to form statements rightly as per language specification – Syntax ( ‘He is tall’ – right, ‘He are tall’ – wrong syntax) 3. Learn to write right statements to carry out given task as per user/customer requirements- semantics – I can and can I? use same words but provides different meaning. Python
  • 5. Python Language elements Token Description Examples Literals/ values/ constant Value that remains same everywhere in the program. Values belong to different data types Number. Numeric value 10 doesn’t change. Hello is a text value which consists of characters. keywords Words used by Python to structure the program and carries specific meaning. if, continue Identifiers (variables/ functions) Variable name given to store value that might change Function name denotes set of statements in the program Temperature=35 Temperature=40 Temperature value changes Operators Symbols to perform operations ( arithmetic, logical, relational etc) +, -, *, / , and, or, =>, < Expressions Combination of values, operators and variable to produce a value X=4+5 Statements Instruction given to computer to perform an action For, if comments Add hints to program and should be ignored during execution # hello world program
  • 6. Let us write a shortest Python program to print the word hello in screen. Create a textfile in notepad or other text editor and type the following line print(“hello”) then save the file in the following format. Filename.py (eg. hello.py) Then run the python program as below python hello.py It will print the text hello in the screen. Is not simple to create and run a python program? Python Language elements
  • 7. Type python and file name in the command line python hello.py How to run Python program
  • 8. # is used to mark comment. Text that follows # will not be executed. Used to write hints for future use. Python comments
  • 9. Let us put the text inside two double quotes next to print inside brackets print(“hello”) In case of numbers, the same print will work print(10). Note that there is no double quotes in case of numbers. Python – Printing characters(text) and numbers
  • 10. print(10) is different from print(“ten”) 10 is a number. “ten” is set of characters(text/string/chars). We can perform different operations on number.(Eg. 10 + 20, 10 -5, 10*5 etc) Whereas chars support different set of operations (Eg. Length of a given word, concatenating two words, occurrence particular letter in a word etc) Python supports specific set of operations on different type of values. Python – values
  • 11. Let us try Python in shell Type Python in command line type is a function that returns data type for given value. type(10) returns int and type(“10”) returns str. Print is a function. Let us see functions usage later. Python – Data types
  • 12. Values, values attributes and operations form data types. Eg integer can represent numbers using digits. Can do +,-,* etc. Python – Data types Numbers • Integer • Float • Boolean • Complex Number Mappings • Dictionary Sequence • String • List • Tuple • Bytes Set types • Sets Python Data Types
  • 13. Keywords must not be used as identifier/variables name. Source:https://docs.python.org Python – Keywords
  • 14. Want to store some value during program execution in computer memory and refer that value using a name as we wish – identifier Variable is one type of identifier. There is no need to mention datatype name while declaring variables in python. In other languages we need to declare variables with data type. marks= 80 // marks is an integer variable Name = “vijay” // Name is a string variable Variables promotes readability print(marks) is better than print(80) Variables promotes reusability Python – Identifier
  • 15. Want to store some value during program execution in computer memory and refer that value using a name as we wish – identifier Variable is one type of identifier. Values can be stored in variables for future use. marks= 80 // marks is an integer variable Name = “vijay” // Name is a string variable print(marks) print(Name) Variables promotes readability in the program. print(marks) is better than print(80) Variables promote reusability Total=mark1 + mark2 Value of mark1 and mark2 are used to assign new value for another variable Total Python – Identifier
  • 16. Variables promote maintainability in the code. print(3.14) Print(3.14) Print(3.14) If you want to change 3.14 into 3.16 you need to change three lines print(3.16) print(3.16) print(3.16) Let us store 3.14 in a variable, then print three times pivalue = 3.14 print(pivalue) print(pivalue) Print(pivalue) Let us change pivalue= 3.16. This only change is enough to print 3.16 three times. Python – Identifier
  • 17. Rules for variablenames There is no need to mention datatype name while declaring variables in python. In other languages we need to declare variables with data type. • Must start with a letteror the underscorecharacter • Variable names cannot start with a number • A variable name can only contain alpha-numericcharacters and underscores(A-z, 0-9, and _ ) • Variable names are case-sensitive (name, Name and NAME are three different variables) Valid variable names num, total, total6 Invalid variable names 6total - starts with number Total* - contains special char global – it’s a Python key word Python – Identifier
  • 18. Next topic : Operators Python – Identifier
  • 19. Python Language elements Token Description Examples Literals/ values/ constant Value that remains same everywhere in the program. Values belong to different data types Number. Numeric value 10 doesn’t change. Hello is a text value which consists of characters. keywords Words used by Python to structure the program and carries specific meaning. if, continue Identifiers (variables/ functions) Variable name given to store value that might change Function name denotes set of statements in the program Temperature=35 Temperature=40 Temperature value changes Operators Symbols to perform operations ( arithmetic, logical, relational etc) +, -, *, / , and, or, =>, < Expressions Combination of values, operators and variable to produce a value X=4+5 Statements Instruction given to computer to perform an action For, if comments Add hints to program and should be ignored during execution # hello world program