SlideShare uma empresa Scribd logo
1 de 20
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

Mais conteúdo relacionado

Mais procurados

Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming LanguageTahani Al-Manie
 
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 FundamentalsPraveen M Jigajinni
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with PythonSushant Mane
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3Syed Farjad Zia Zaidi
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
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 immutabilityMohd Sajjad
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in pythonJothi Thilaga P
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II NotesAndrew Raj
 
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 commentsNilimesh Halder
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introductionAnanda Kumar HN
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slidesrfojdar
 
Data types in python lecture (2)
Data types in python lecture (2)Data types in python lecture (2)
Data types in python lecture (2)Ali ٍSattar
 
Python data type
Python data typePython data type
Python data typenuripatidar
 

Mais procurados (20)

Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
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
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
 
Introduction To Programming with Python-3
Introduction To Programming with Python-3Introduction To Programming with Python-3
Introduction To Programming with Python-3
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
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
 
Values and Data types in python
Values and Data types in pythonValues and Data types in python
Values and Data types in python
 
Python revision tour II
Python revision tour IIPython revision tour II
Python revision tour II
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Data Handling
Data HandlingData Handling
Data Handling
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes
 
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
 
Chapter 10 data handling
Chapter 10 data handlingChapter 10 data handling
Chapter 10 data handling
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Oop with c++ notes unit 01 introduction
Oop with c++ notes   unit 01 introductionOop with c++ notes   unit 01 introduction
Oop with c++ notes unit 01 introduction
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Data types in python lecture (2)
Data types in python lecture (2)Data types in python lecture (2)
Data types in python lecture (2)
 
Python data type
Python data typePython data type
Python data type
 

Semelhante a Python Data Types

Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.pptjaba kumar
 
python ppt | Python Course In Ghaziabad | Scode Network Institute
python ppt | Python Course In Ghaziabad | Scode Network Institutepython ppt | Python Course In Ghaziabad | Scode Network Institute
python ppt | Python Course In Ghaziabad | Scode Network InstituteScode Network Institute
 
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
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...manikamr074
 
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptxa9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptxcigogag569
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizeIruolagbePius
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfKosmikTech1
 
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdfCSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdfAbdulmalikAhmadLawan2
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdfsamiwaris2
 

Semelhante a Python Data Types (20)

PYTHON.pdf
PYTHON.pdfPYTHON.pdf
PYTHON.pdf
 
Python - Module 1.ppt
Python - Module 1.pptPython - Module 1.ppt
Python - Module 1.ppt
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
GE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_NotesGE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_Notes
 
python ppt | Python Course In Ghaziabad | Scode Network Institute
python ppt | Python Course In Ghaziabad | Scode Network Institutepython ppt | Python Course In Ghaziabad | Scode Network Institute
python ppt | Python Course In Ghaziabad | Scode Network Institute
 
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
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...PART - 1  Python Introduction- Variables- Data types - Numeric- String- Boole...
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
 
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptxa9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
UNIT1Lesson 2.pptx
UNIT1Lesson 2.pptxUNIT1Lesson 2.pptx
UNIT1Lesson 2.pptx
 
Unit 2 python
Unit 2 pythonUnit 2 python
Unit 2 python
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 
How To Tame Python
How To Tame PythonHow To Tame Python
How To Tame Python
 
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdfpython-online&offline-training-in-kphb-hyderabad (1) (1).pdf
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
 
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdfCSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
CSC2308 - PRINCIPLE OF PROGRAMMING II.pdf
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Python
PythonPython
Python
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Python Training in Chandigarh
Python Training in ChandigarhPython Training in Chandigarh
Python Training in Chandigarh
 

Último

The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Último (20)

The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

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