SlideShare a Scribd company logo
1
Introduction to Programming
with Python
Why Python?
Python is object-oriented
Structure supports such concepts as polymorphism, operation overloading, and multiple inheritance
It's free (open source)
Downloading and installing Python is free and easy
Source code is easily accessible
Free doesn't mean unsupported! Online Python community is huge
It's portable
Python runs virtually every major platform used today
As long as you have a compatible Python interpreter installed, Python programs will run in exactly
the same manner, irrespective of platform
It's powerful
Dynamic typing
Built-in types and tools
Library utilities
Third party utilities (e.g. Numeric, NumPy, SciPy)
Automatic memory management
Why Python? (Contd…)
It's mixable
Python can be linked to components written in other languages easily
Linking to fast, compiled code is useful to computationally intensive problems
Python is good for code steering and for merging multiple programs in otherwise conflicting languages
Python/C integration is quite common
It's easy to use
Rapid turnaround: no intermediate compile and link steps as in C or C++
Python programs are compiled automatically to an intermediate form called bytecode, which the interpreter then
reads
This gives Python the development speed of an interpreter without the performance loss inherent in purely
interpreted languages
It's easy to learn
Structure and syntax are pretty intuitive and easy to grasp
Compiling and interpreting
 Many languages require you to compile (translate) your program into a form that the machine
understands.
 Python is instead interpreted into machine instructions everytime read by PVM implemented
independent from hardware.(Bytecode/.pyc)
compile execute
output
source code
Hello.java
byte code
Hello.class
interpret
output
source code
Hello.py
Which IDE to use?
 IDLE (Integrated DeveLopment Environment) – Included with Python
download from www.python.org
 Eclipse with PyDev
 Pycharm (Community Edition)
 Komodo Edit
 …. And a lot more.
IDLE Modes
 IDLE provides two kinds of modes:
 Interactive mode – Good for beginners and for testing small snippets of code
and getting an overall feel of the programming language.
 Script mode – The next logical step after learning a few of the basics of the
language is creating programs/ snippets.
 We will use IDLE/Spyder/Anaconda in class.
Lets practice:-
Lets write a program to say hello.
print is the command… but wait….
i) print (“Hello”) #3.x
or
ii)print “hello” #2.x
Important differences between Python 2.x and Python
3.x with examples
 Division operator
 print function
 Unicode
 xrange
 Error Handling (as keyword)
 _future_ module
Comments
 Start comments with # – the rest of line is ignored.
 Can include a “documentation string” as the first
line of any new function or class that you define.
 The development environment, debugger, and other
tools use it: it’s good style to include one.
“““This is the docstring. This
function does blah blah blah.”””
# The code would go here...
Keywords
 They are the words used by Python interpreter to recognize the structure of
program.
As these words have specific meaning for interpreter, they cannot be
used for any other purpose.
 A partial list of keywords in Python 2.7 is
Operators
 Operators are special symbols which represents computation. They are
applied on operand(s), which can be values or variables. Same operator can
behave differently on different data types. Operators when applied on
operands form an expression.
 Operators are categorized as Arithmetic, Relational, Logical and Assignment.
Value and variables when used with operator are known as operands.
Arithmetic Operators
Arithmetic Operators contd…
Relational Operators
Relational Operators contd…
Logical Operator
Assignment Operators
Data Types
Data
Types
Numbers
Integer
Boolean
Floating
Point
Complex
None Sequence
String
Tuple
List
Sets Mappings
Dictionary
Prerequisites:-
 Concept of variable in respect of python. (not a container anymore)
 Concept of mutable/immutable datatype.(modifiable/not modifiable objects)
Number
 Number data type stores Numerical Values. This data type is immutable i.e.
value of its object cannot be changed (we will talk about this aspect later).
 These are of three different types:
a) Integer & Long
b) Float/floating point
c) Complex
d) Boolean
BACK
None
 This is special data type with single value. It is used to signify the absence of
value/false in a situation. It is represented by None
BACK
Sequence
 A sequence is an ordered collection of items, indexed by positive integers. It
is combination of mutable and non mutable data types. Three types of
sequence data type available in Python are :
a) Strings
b) Lists
c) Tuples.
BACK
String
 String is an ordered sequence of letters/characters. They are enclosed in
single quotes (‘’) or double quotes (“”). The quotes are not part of string. They
only tell the computer where the string constant begins and ends. They can have
any character or sign, including space in them. These are immutable data
types. We will learn about immutable data types while dealing with third
aspect of object i.e. value of object.
Example
>>> a = 'Ram'
 A string with length 1 represents a character in Python. BACK
List
 List is also a sequence of values of any type. Values in the list are called
elements / items. These are mutable and indexed/ordered. List is enclosed in
square brackets.
Example
l = [“spam , 20.5,5]
‟
BACK
Tuples
 Tuples are a sequence of values of any type, and are indexed by
integers. They are immutable. Tuples are enclosed in ().
BACK
Sets
 Set is an unordered collection of values, of any type, with no duplicate entry.
Sets are immutable.
Example
s = set ([1,2,34])
BACK
Mapping and Dictionaries
 Mapping
This data type is unordered and mutable. Dictionaries fall under
Mappings.
Dictionaries: Can store any number of python objects. What they store is a
key – value pairs, which are accessed using key. Dictionary is enclosed in
curly brackets.
Example
d = {1:'a',2:'b',3:'c'}
Thank
You!!!

More Related Content

PPTX
Introduction to Python for Data Science and Machine Learning
PPT
Python - Module 1.ppt
PDF
Python_Unit_1.pdf
PDF
GE3151_PSPP_UNIT_2_Notes
PDF
Intro-to-Python-Part-1-first-part-edition.pdf
PDF
Python Programming Course Presentations
PDF
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
PPTX
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
Introduction to Python for Data Science and Machine Learning
Python - Module 1.ppt
Python_Unit_1.pdf
GE3151_PSPP_UNIT_2_Notes
Intro-to-Python-Part-1-first-part-edition.pdf
Python Programming Course Presentations
Top 80 Interview Questions on Python for Data Science | Tutort - Best Data Sc...
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx

Similar to Introduction to Programming.pptx ok ok ok (20)

PDF
Python for katana
PDF
problem solving and python programming UNIT 2.pdf
PDF
Problem Solving and Python Programming UNIT 2.pdf
PPTX
Introduction on basic python and it's application
PDF
🐍⚡ “Python Panache: Code Like a Pro, Not a Programmer!”
PDF
Python-01| Fundamentals
PDF
data base nd analystics slybysss for the students to improbvr
DOCX
Python Course.docx
PDF
Python interview questions and answers
PDF
Python Data Types
DOCX
Python interview questions and answers
PDF
How To Tame Python
PDF
Python programming
PDF
Zero to Hero - Introduction to Python3
PDF
Top Most Python Interview Questions.pdf
PPTX
Python Programming for problem solving.pptx
PPTX
Programming paradigms Techniques_part2.pptx
PPT
presentation_intro_to_python
PPT
presentation_intro_to_python_1462930390_181219.ppt
Python for katana
problem solving and python programming UNIT 2.pdf
Problem Solving and Python Programming UNIT 2.pdf
Introduction on basic python and it's application
🐍⚡ “Python Panache: Code Like a Pro, Not a Programmer!”
Python-01| Fundamentals
data base nd analystics slybysss for the students to improbvr
Python Course.docx
Python interview questions and answers
Python Data Types
Python interview questions and answers
How To Tame Python
Python programming
Zero to Hero - Introduction to Python3
Top Most Python Interview Questions.pdf
Python Programming for problem solving.pptx
Programming paradigms Techniques_part2.pptx
presentation_intro_to_python
presentation_intro_to_python_1462930390_181219.ppt
Ad

Recently uploaded (20)

PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PDF
Fluorescence-microscope_Botany_detailed content
PDF
Business Analytics and business intelligence.pdf
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
Database Infoormation System (DBIS).pptx
PPTX
Introduction to machine learning and Linear Models
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Business Acumen Training GuidePresentation.pptx
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPT
Quality review (1)_presentation of this 21
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
IB Computer Science - Internal Assessment.pptx
Business Ppt On Nestle.pptx huunnnhhgfvu
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
climate analysis of Dhaka ,Banglades.pptx
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Fluorescence-microscope_Botany_detailed content
Business Analytics and business intelligence.pdf
Clinical guidelines as a resource for EBP(1).pdf
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Database Infoormation System (DBIS).pptx
Introduction to machine learning and Linear Models
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Business Acumen Training GuidePresentation.pptx
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Quality review (1)_presentation of this 21
Ad

Introduction to Programming.pptx ok ok ok

  • 2. Why Python? Python is object-oriented Structure supports such concepts as polymorphism, operation overloading, and multiple inheritance It's free (open source) Downloading and installing Python is free and easy Source code is easily accessible Free doesn't mean unsupported! Online Python community is huge It's portable Python runs virtually every major platform used today As long as you have a compatible Python interpreter installed, Python programs will run in exactly the same manner, irrespective of platform It's powerful Dynamic typing Built-in types and tools Library utilities Third party utilities (e.g. Numeric, NumPy, SciPy) Automatic memory management
  • 3. Why Python? (Contd…) It's mixable Python can be linked to components written in other languages easily Linking to fast, compiled code is useful to computationally intensive problems Python is good for code steering and for merging multiple programs in otherwise conflicting languages Python/C integration is quite common It's easy to use Rapid turnaround: no intermediate compile and link steps as in C or C++ Python programs are compiled automatically to an intermediate form called bytecode, which the interpreter then reads This gives Python the development speed of an interpreter without the performance loss inherent in purely interpreted languages It's easy to learn Structure and syntax are pretty intuitive and easy to grasp
  • 4. Compiling and interpreting  Many languages require you to compile (translate) your program into a form that the machine understands.  Python is instead interpreted into machine instructions everytime read by PVM implemented independent from hardware.(Bytecode/.pyc) compile execute output source code Hello.java byte code Hello.class interpret output source code Hello.py
  • 5. Which IDE to use?  IDLE (Integrated DeveLopment Environment) – Included with Python download from www.python.org  Eclipse with PyDev  Pycharm (Community Edition)  Komodo Edit  …. And a lot more.
  • 6. IDLE Modes  IDLE provides two kinds of modes:  Interactive mode – Good for beginners and for testing small snippets of code and getting an overall feel of the programming language.  Script mode – The next logical step after learning a few of the basics of the language is creating programs/ snippets.  We will use IDLE/Spyder/Anaconda in class.
  • 7. Lets practice:- Lets write a program to say hello. print is the command… but wait…. i) print (“Hello”) #3.x or ii)print “hello” #2.x
  • 8. Important differences between Python 2.x and Python 3.x with examples  Division operator  print function  Unicode  xrange  Error Handling (as keyword)  _future_ module
  • 9. Comments  Start comments with # – the rest of line is ignored.  Can include a “documentation string” as the first line of any new function or class that you define.  The development environment, debugger, and other tools use it: it’s good style to include one. “““This is the docstring. This function does blah blah blah.””” # The code would go here...
  • 10. Keywords  They are the words used by Python interpreter to recognize the structure of program. As these words have specific meaning for interpreter, they cannot be used for any other purpose.  A partial list of keywords in Python 2.7 is
  • 11. Operators  Operators are special symbols which represents computation. They are applied on operand(s), which can be values or variables. Same operator can behave differently on different data types. Operators when applied on operands form an expression.  Operators are categorized as Arithmetic, Relational, Logical and Assignment. Value and variables when used with operator are known as operands.
  • 19. Prerequisites:-  Concept of variable in respect of python. (not a container anymore)  Concept of mutable/immutable datatype.(modifiable/not modifiable objects)
  • 20. Number  Number data type stores Numerical Values. This data type is immutable i.e. value of its object cannot be changed (we will talk about this aspect later).  These are of three different types: a) Integer & Long b) Float/floating point c) Complex d) Boolean BACK
  • 21. None  This is special data type with single value. It is used to signify the absence of value/false in a situation. It is represented by None BACK
  • 22. Sequence  A sequence is an ordered collection of items, indexed by positive integers. It is combination of mutable and non mutable data types. Three types of sequence data type available in Python are : a) Strings b) Lists c) Tuples. BACK
  • 23. String  String is an ordered sequence of letters/characters. They are enclosed in single quotes (‘’) or double quotes (“”). The quotes are not part of string. They only tell the computer where the string constant begins and ends. They can have any character or sign, including space in them. These are immutable data types. We will learn about immutable data types while dealing with third aspect of object i.e. value of object. Example >>> a = 'Ram'  A string with length 1 represents a character in Python. BACK
  • 24. List  List is also a sequence of values of any type. Values in the list are called elements / items. These are mutable and indexed/ordered. List is enclosed in square brackets. Example l = [“spam , 20.5,5] ‟ BACK
  • 25. Tuples  Tuples are a sequence of values of any type, and are indexed by integers. They are immutable. Tuples are enclosed in (). BACK
  • 26. Sets  Set is an unordered collection of values, of any type, with no duplicate entry. Sets are immutable. Example s = set ([1,2,34]) BACK
  • 27. Mapping and Dictionaries  Mapping This data type is unordered and mutable. Dictionaries fall under Mappings. Dictionaries: Can store any number of python objects. What they store is a key – value pairs, which are accessed using key. Dictionary is enclosed in curly brackets. Example d = {1:'a',2:'b',3:'c'}