SlideShare a Scribd company logo
BASICS OF PYTHON
PGDCA
INTRODUCTION
• Python is an interpretive language.
• This means that your code is not directly run by the hardware. It is instead passed to a
virtual machine, which is just another programme that reads and interprets your code. If
your code used the ‘+’ operation, this would be recognised by the interpreter at run time,
which would then call its own internal function ‘add(a,b)’, which would then execute the
machine code ‘ADD’.
• This is in contrast to compiled languages, where your code is translated into native
machine instructions, which are then directly executed by the hardware. Here, the ‘+’ in
your code would be translated directly in the ‘ADD’ machine code.
ADVANTAGES OF PYTHON
Because Python is an interpretive language, it
has a number of advantages:
• Automatic memory management.
• Expressivity and syntax that is ‘English’.
• Ease of programming.
• Minimises development time.
• Python also has a focus on importing
modules, a feature that makes it useful for
scientific computing.
DISADVANTAGES
• Interpreted languages are slower than compiled languages.
• The modules that you import are developed in a
decentralised manner; this can cause issues based upon
individual assumptions.
• Multi-threading is hard in Python.
VERSIONS OF PYTHON
• There are currently two versions of Python in use; Python 2 and
Python 3.
• Python 3 is not backward compatible with Python 2.
• A lot of the imported modules were only available in Python 2
for quite some time, leading to a slow adoption of Python 3.
However, this not really an issue anymore.
• Support for Python 2 will end in 2020.
THE ANACONDA IDE…
• The Anaconda distribution is the most popular Python
distribution out there.
• Most importable packages are pre-installed.
• Offers a nice GUI in the form of Spyder.
• Before we go any further, let’s open Spyder:
ppt notes for python language variable data types
KEYWORDS
Python keywords are special reserved words that have
specific meanings and purposes and can’t be used for anything
but those specific purposes. These keywords are always
available—you’ll never have to import them into your code.
Python keywords are different from Python’s built-in
functions and types. The built-in functions and types are also
always available, but they aren’t as restrictive as the keywords in
their usage. As of Python 3.8, there are thirty-five keywords in
Python.
VARIABLES
• Variables in python can contain alphanumerical characters and
some special characters.
• By convention, it is common to have variable names that start
with lower case letters and have class names beginning with a
capital letter; but you can do whatever you want.
• Some keywords are reserved and cannot be used as variable
names due to them serving an in-built Python function; i.e. and,
continue, break. Your IDE will let you know if you try to use
one of these.
• Python is dynamically typed; the type of the variable is derived
from the value it is assigned.
VARIABLE TYPES
• Integer (int)
• Float (float)
• String (str)
• Boolean (bool)
• Complex (complex)
• […]
• User defined
(classes)
• A variable is assigned using the =
operator; i.e:
In: Out:
• The print() function is used to print
something to the screen.
• You can always check the type of a variable using the type() function.
In: Out:
• Check the type of one of your
variables.
• Variables can be cast to a different type.
In: Out:
OPERATORS
Operators are used to perform operations on variables and
values. E.g. print(10 + 5)
Python divides the operators in the following groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators
ARITHMETIC OPERATORS
The arithmetic operators:
• Addition: +
• Subtract: -
• Multiplication: *
• Division: /
• Power: **
• Write a couple of operations
using the arithmetic
operators, and print the
results to the screen.
In: Out:
A QUICK NOTE ON THE INCREMENT
OPERATOR SHORTHAND
• Python has a common idiom that is not necessary, but which is used frequently and is therefore worth
noting:
x += 1
Is the same as:
x = x + 1
• This also works for other operators:
x += y # adds y to the value of x
x *= y # multiplies x by the value y
x -= y # subtracts y from x
x /= y # divides x by y
BOOLEAN OPERATORS
Boolean operators are useful when making
conditional statements, we will cover these in-
depth later.
• and
• or
• not
COMPARISON OPERATORS
• Greater than: >
• Lesser than: <
• Greater than or equal to: >=
• Lesser than or equal to: <=
• Is equal to: ==
In:
Out:
• Write a couple of operations
using comparison operators;
i.e.

More Related Content

Similar to ppt notes for python language variable data types (20)

PPTX
Welcome to python workshop
Mukul Kirti Verma
 
PDF
Introduction to Python
Mohammed Sikander
 
PDF
Introduction of Python
ZENUS INFOTECH INDIA PVT. LTD.
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
Introduction to python
MaheshPandit16
 
PPTX
Learn about Python power point presentation
omsumukh85
 
PPTX
python_module_.................................................................
VaibhavSrivastav52
 
PPTX
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
PPTX
Lecture1_introduction to python.pptx
MohammedAlYemeni1
 
PDF
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
PDF
computer science CLASS 11 AND 12 SYLLABUS.pdf
SomnathSaha63
 
PPTX
Chapter1 python introduction syntax general
ssuser77162c
 
DOCX
A Introduction Book of python For Beginners.docx
kumarrabinderkumar77
 
PPTX
Python Programming-1.pptx of python by computer
sharanyarashmir5
 
PPTX
UNIT 1 .pptx
Prachi Gawande
 
PDF
Sessisgytcfgggggggggggggggggggggggggggggggg
pawankamal3
 
PPTX
python ppt | Python Course In Ghaziabad | Scode Network Institute
Scode Network Institute
 
PPTX
2. Getting Started with Python second lesson .pptx
Primary2Primary2
 
Welcome to python workshop
Mukul Kirti Verma
 
Introduction to Python
Mohammed Sikander
 
Introduction of Python
ZENUS INFOTECH INDIA PVT. LTD.
 
Python basic programing language for automation
DanialHabibi2
 
Introduction to python
MaheshPandit16
 
Learn about Python power point presentation
omsumukh85
 
python_module_.................................................................
VaibhavSrivastav52
 
python introduction initial lecture unit1.pptx
ChandraPrakash715640
 
Lecture1_introduction to python.pptx
MohammedAlYemeni1
 
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
Basic concept of Python.pptx includes design tool, identifier, variables.
supriyasarkar38
 
computer science CLASS 11 AND 12 SYLLABUS.pdf
SomnathSaha63
 
Chapter1 python introduction syntax general
ssuser77162c
 
A Introduction Book of python For Beginners.docx
kumarrabinderkumar77
 
Python Programming-1.pptx of python by computer
sharanyarashmir5
 
UNIT 1 .pptx
Prachi Gawande
 
Sessisgytcfgggggggggggggggggggggggggggggggg
pawankamal3
 
python ppt | Python Course In Ghaziabad | Scode Network Institute
Scode Network Institute
 
2. Getting Started with Python second lesson .pptx
Primary2Primary2
 

More from SukhpreetSingh519414 (10)

PPTX
KIRSET24 template fggppt - Copy (1).pptx
SukhpreetSingh519414
 
PDF
Decimals intjsshshshshsjsjshdhdhsjsjsjdh
SukhpreetSingh519414
 
PPTX
python full notes data types string and tuple
SukhpreetSingh519414
 
PPTX
CPP-overviews notes variable data types notes
SukhpreetSingh519414
 
PDF
ppt notes python language operators and data
SukhpreetSingh519414
 
PDF
ppt python notes list tuple data types ope
SukhpreetSingh519414
 
PDF
C%20ARRAYS.pdf.pdf
SukhpreetSingh519414
 
PPTX
java exception.pptx
SukhpreetSingh519414
 
PPTX
finap ppt conference.pptx
SukhpreetSingh519414
 
PPTX
final security ppt.pptx
SukhpreetSingh519414
 
KIRSET24 template fggppt - Copy (1).pptx
SukhpreetSingh519414
 
Decimals intjsshshshshsjsjshdhdhsjsjsjdh
SukhpreetSingh519414
 
python full notes data types string and tuple
SukhpreetSingh519414
 
CPP-overviews notes variable data types notes
SukhpreetSingh519414
 
ppt notes python language operators and data
SukhpreetSingh519414
 
ppt python notes list tuple data types ope
SukhpreetSingh519414
 
C%20ARRAYS.pdf.pdf
SukhpreetSingh519414
 
java exception.pptx
SukhpreetSingh519414
 
finap ppt conference.pptx
SukhpreetSingh519414
 
final security ppt.pptx
SukhpreetSingh519414
 
Ad

Recently uploaded (20)

PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Dimensions of Societal Planning in Commonism
StefanMz
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Ad

ppt notes for python language variable data types

  • 2. INTRODUCTION • Python is an interpretive language. • This means that your code is not directly run by the hardware. It is instead passed to a virtual machine, which is just another programme that reads and interprets your code. If your code used the ‘+’ operation, this would be recognised by the interpreter at run time, which would then call its own internal function ‘add(a,b)’, which would then execute the machine code ‘ADD’. • This is in contrast to compiled languages, where your code is translated into native machine instructions, which are then directly executed by the hardware. Here, the ‘+’ in your code would be translated directly in the ‘ADD’ machine code.
  • 3. ADVANTAGES OF PYTHON Because Python is an interpretive language, it has a number of advantages: • Automatic memory management. • Expressivity and syntax that is ‘English’. • Ease of programming. • Minimises development time. • Python also has a focus on importing modules, a feature that makes it useful for scientific computing.
  • 4. DISADVANTAGES • Interpreted languages are slower than compiled languages. • The modules that you import are developed in a decentralised manner; this can cause issues based upon individual assumptions. • Multi-threading is hard in Python.
  • 5. VERSIONS OF PYTHON • There are currently two versions of Python in use; Python 2 and Python 3. • Python 3 is not backward compatible with Python 2. • A lot of the imported modules were only available in Python 2 for quite some time, leading to a slow adoption of Python 3. However, this not really an issue anymore. • Support for Python 2 will end in 2020.
  • 6. THE ANACONDA IDE… • The Anaconda distribution is the most popular Python distribution out there. • Most importable packages are pre-installed. • Offers a nice GUI in the form of Spyder. • Before we go any further, let’s open Spyder:
  • 8. KEYWORDS Python keywords are special reserved words that have specific meanings and purposes and can’t be used for anything but those specific purposes. These keywords are always available—you’ll never have to import them into your code. Python keywords are different from Python’s built-in functions and types. The built-in functions and types are also always available, but they aren’t as restrictive as the keywords in their usage. As of Python 3.8, there are thirty-five keywords in Python.
  • 9. VARIABLES • Variables in python can contain alphanumerical characters and some special characters. • By convention, it is common to have variable names that start with lower case letters and have class names beginning with a capital letter; but you can do whatever you want. • Some keywords are reserved and cannot be used as variable names due to them serving an in-built Python function; i.e. and, continue, break. Your IDE will let you know if you try to use one of these. • Python is dynamically typed; the type of the variable is derived from the value it is assigned.
  • 10. VARIABLE TYPES • Integer (int) • Float (float) • String (str) • Boolean (bool) • Complex (complex) • […] • User defined (classes) • A variable is assigned using the = operator; i.e: In: Out: • The print() function is used to print something to the screen.
  • 11. • You can always check the type of a variable using the type() function. In: Out: • Check the type of one of your variables.
  • 12. • Variables can be cast to a different type. In: Out:
  • 13. OPERATORS Operators are used to perform operations on variables and values. E.g. print(10 + 5) Python divides the operators in the following groups: • Arithmetic operators • Assignment operators • Comparison operators • Logical operators • Identity operators • Membership operators • Bitwise operators
  • 14. ARITHMETIC OPERATORS The arithmetic operators: • Addition: + • Subtract: - • Multiplication: * • Division: / • Power: ** • Write a couple of operations using the arithmetic operators, and print the results to the screen. In: Out:
  • 15. A QUICK NOTE ON THE INCREMENT OPERATOR SHORTHAND • Python has a common idiom that is not necessary, but which is used frequently and is therefore worth noting: x += 1 Is the same as: x = x + 1 • This also works for other operators: x += y # adds y to the value of x x *= y # multiplies x by the value y x -= y # subtracts y from x x /= y # divides x by y
  • 16. BOOLEAN OPERATORS Boolean operators are useful when making conditional statements, we will cover these in- depth later. • and • or • not
  • 17. COMPARISON OPERATORS • Greater than: > • Lesser than: < • Greater than or equal to: >= • Lesser than or equal to: <= • Is equal to: == In: Out: • Write a couple of operations using comparison operators; i.e.