KEMBAR78
2. Getting Started with Python second lesson .pptx
Introduction of Python
What is Python?
Python is general Purpose High Level Programing Language
It can be used For
1. Desktop Application
2. Web Application
3. Mobile Application
Popular apps developed in Python
About Python
• It has very simple and straight forward Syntax.
• Python is case sensitive Language.
• It is an Object Oriented Programing Language.
• Dynamically Typed .
• Executed by interpreter
• Can run in various operating systems. Indentation is used in place of Curly Braces.
• Use variable without declaration.
• It is an Interpreted Language.
Features
• Emphasis on Code readability.
• Automatic Memory Management.
• Dynamically Typed
• Large Library
• Platform Independent
Features
• Easy to use – Due to simple syntax rule
• Interpreted language – Code execution & interpretation line by line
• Cross-platform language – It can run on windows, Linux, Macintosh
etc. equally
• Expressive language – Less code to be written as it itself express the
purpose of the code.
• Completeness – Support wide rage of library
• Free & Open Source – Can be downloaded freely and source code can
be modify for improvement
Working with python
• To run a python pgm, install a python interpreter at first
• Interpreter is also called as python shell
• >>>shows python prompt is ready to take instructions
• We can type in this prompt to execute them using python
interpreter
Two ways of python interpreter
• Interactive mode
• Script mode
Interactive mode
• Simply type in >>> prompt.
• Immediately executed of individual statement
• Convini ent for testing single line code for instant execution
• We cannot save the statements for future use
• Retype and run again
• Eg:
• 1+2
• Answer we get immediately
Script mode
• In a file, we type, save then execute it
• Extension is .py
• Tell the students to write a program to show print statements
in script mode
Python keywords
• Reserved words
• Each word has a specific meaning
• we use keyword only for the purpose for which it has been
defined
• Python is Case sensitive , so exactly we have to write
• We cannot use a keyword as a variable name, function name or any
other identifier. They are used to define the syntax and structure of the
Python language.
• In Python, keywords are case sensitive.
• There are 33 keywords in Python 3.7. This number can vary slightly
over the course of time.
• All the keywords except True, False and None are in lowercase and
they must be written as they are..
List of key words
identifiers
• Used to identify a variable, function or entity in program
• Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or
digits (0 to 9) or an underscore _ . ...
• An identifier cannot start with a digit. ...
• Keywords cannot be used as identifiers. ...
• We cannot use special symbols like !, @, #, $, % etc. ...
• An identifier can be of any length.
• Ex: marks 1, mark2, avg like that words used to identify by us for write a program
• Area=length*breadth
variables
•A variable is a label that you can assign a value to it. The
value of a variable can change throughout the program.
•A=‘m’
•Message=“keep smiling”
•Price=587.6
comments
• Remark or note in the source code
• Easier for other persons also to understand
• #sign starts till end of # considered as comment
• Simply ignores while executing the statement
Data types
Variables can store data of different types, and different types can do
different things.
Python has the following data types built-in by default, in these
categories:
Numbers or numeric
Type description
example
Int integer numbers
-12,-3,0,125
Float real or floating numbers -2.04, 4.0,
14.23
Complex complex numbers 3+4i,
2-2i
Boolean (bool)
• It is a subtype of integer
• It is a unique data type
• Consists of two constants (True and False)
• Boolean True value is non-zero, non null, non empty
• Boolean False is value zero
sequence
Ordered collection of items
• String
• List
• tuple
string
•– group of characters
•->>>str1=‘hello’
•->>>str2=“452”
•We cannot perform numerical operations on
strings, even when the string contains a value as
in str2
list
Sequence of items separated by commas and the items enclosed in
square brackets[]
Ex:
>>>list1=[10,3.5,”new delhi”,’welcome’,50]
>>>print(list1)
tuple
• Sequence of items separated by commas and the items enclosed
in parenthesis()
• Ex
• Tuple1=(10,20,”apple”,3.4,’a’)
• Print(tuple1)
SET
• Unordered collection of items
• {}
• No duplicate entries
• Ex
• Set1={10,20,10,’apple’}
• Print(type(set1))
• <class’set’>
• Print(set1)
• Output{10,20,’apple’}
NONE
• Special data type with a single value
• Used to signify the absence of value in a situation
• None supports no special operations, and it is neither false nor
zero
mapping
• Unordered datatype
• One standard mapping datatype is called dictionary
• Holds data items in key value pairs
• {}
• Dictionaries permit faster access to data
• Every key is separated from its value using a colon: sign
• >>>dict1={‘fruit’:’apple’,’climate’:’cold’}
• Print(dict1)
Mutable and immutable data types
• List and dictionary are mutable datatypes
• Refer page no 98 in NCERT BOOK
• MEMORY ALLOCATION OF num1, num2, num1=num1+100
Deciding usage of python data types
• For storing names of students, easy to update when new
admission join
• Tuples use when no change ex- names of months in a year
• When need uniqueness , avoid duplicacy, we use sets
• When we need logical association between the key:value pair,
advising to use dictionaries
• Ex: mobile phone book is a good application of dictionary
operators
• To perform mathematical or logical operation on values
• Values that the operators work on are called operands
• Ex: 10+num,
• Value is 10
• Variable num operands and the + sign is an operator
Arithmetic operators
RELATIONAL OPERATORS
assignment operators
logical operators
identity operators
membership operator
•Pg no 100 to 104 in NCERT BOOK to be
work out in lab
expression
• Combination of constants, variables and operators
• Always evaluates a value
• A value or variable is also considered as an expression but a
standalone operator is not an expression
• Precedence Of expression refer pg 105 in NCERT
STATEMENT
• IN PYTHON, A STATEMENT IS A UNIT OF CODE THAT THE PYTHON
INTERPRETER CAN EXECUTE PG NO 106 IN NCERT BOOK
INPUT, OUTPUT
• It accepts all user input as string
• Input([prompt])
• Input function terminated by pressing enter key
Type conversion
• Pg no 108,109 in NCERT BOOK
• IMPLICIT , EXPLICIT CONVERSION
DEBUGGING
• SYNTAX ERRORS
• LOGICAL ERRORS
• RUNTIME ERRORS
THANK YOU

2. Getting Started with Python second lesson .pptx

  • 1.
    Introduction of Python Whatis Python? Python is general Purpose High Level Programing Language It can be used For 1. Desktop Application 2. Web Application 3. Mobile Application
  • 2.
  • 3.
    About Python • Ithas very simple and straight forward Syntax. • Python is case sensitive Language. • It is an Object Oriented Programing Language. • Dynamically Typed . • Executed by interpreter • Can run in various operating systems. Indentation is used in place of Curly Braces. • Use variable without declaration. • It is an Interpreted Language.
  • 4.
    Features • Emphasis onCode readability. • Automatic Memory Management. • Dynamically Typed • Large Library • Platform Independent
  • 5.
    Features • Easy touse – Due to simple syntax rule • Interpreted language – Code execution & interpretation line by line • Cross-platform language – It can run on windows, Linux, Macintosh etc. equally • Expressive language – Less code to be written as it itself express the purpose of the code. • Completeness – Support wide rage of library • Free & Open Source – Can be downloaded freely and source code can be modify for improvement
  • 6.
    Working with python •To run a python pgm, install a python interpreter at first • Interpreter is also called as python shell • >>>shows python prompt is ready to take instructions • We can type in this prompt to execute them using python interpreter
  • 7.
    Two ways ofpython interpreter • Interactive mode • Script mode
  • 8.
    Interactive mode • Simplytype in >>> prompt. • Immediately executed of individual statement • Convini ent for testing single line code for instant execution • We cannot save the statements for future use • Retype and run again • Eg: • 1+2 • Answer we get immediately
  • 9.
    Script mode • Ina file, we type, save then execute it • Extension is .py • Tell the students to write a program to show print statements in script mode
  • 10.
    Python keywords • Reservedwords • Each word has a specific meaning • we use keyword only for the purpose for which it has been defined • Python is Case sensitive , so exactly we have to write
  • 11.
    • We cannotuse a keyword as a variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language. • In Python, keywords are case sensitive. • There are 33 keywords in Python 3.7. This number can vary slightly over the course of time. • All the keywords except True, False and None are in lowercase and they must be written as they are..
  • 12.
  • 13.
    identifiers • Used toidentify a variable, function or entity in program • Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore _ . ... • An identifier cannot start with a digit. ... • Keywords cannot be used as identifiers. ... • We cannot use special symbols like !, @, #, $, % etc. ... • An identifier can be of any length. • Ex: marks 1, mark2, avg like that words used to identify by us for write a program • Area=length*breadth
  • 14.
    variables •A variable isa label that you can assign a value to it. The value of a variable can change throughout the program. •A=‘m’ •Message=“keep smiling” •Price=587.6
  • 15.
    comments • Remark ornote in the source code • Easier for other persons also to understand • #sign starts till end of # considered as comment • Simply ignores while executing the statement
  • 16.
    Data types Variables canstore data of different types, and different types can do different things. Python has the following data types built-in by default, in these categories:
  • 18.
    Numbers or numeric Typedescription example Int integer numbers -12,-3,0,125 Float real or floating numbers -2.04, 4.0, 14.23 Complex complex numbers 3+4i, 2-2i
  • 19.
    Boolean (bool) • Itis a subtype of integer • It is a unique data type • Consists of two constants (True and False) • Boolean True value is non-zero, non null, non empty • Boolean False is value zero
  • 20.
    sequence Ordered collection ofitems • String • List • tuple
  • 21.
    string •– group ofcharacters •->>>str1=‘hello’ •->>>str2=“452” •We cannot perform numerical operations on strings, even when the string contains a value as in str2
  • 22.
    list Sequence of itemsseparated by commas and the items enclosed in square brackets[] Ex: >>>list1=[10,3.5,”new delhi”,’welcome’,50] >>>print(list1)
  • 23.
    tuple • Sequence ofitems separated by commas and the items enclosed in parenthesis() • Ex • Tuple1=(10,20,”apple”,3.4,’a’) • Print(tuple1)
  • 24.
    SET • Unordered collectionof items • {} • No duplicate entries • Ex • Set1={10,20,10,’apple’} • Print(type(set1)) • <class’set’> • Print(set1) • Output{10,20,’apple’}
  • 25.
    NONE • Special datatype with a single value • Used to signify the absence of value in a situation • None supports no special operations, and it is neither false nor zero
  • 26.
    mapping • Unordered datatype •One standard mapping datatype is called dictionary • Holds data items in key value pairs • {} • Dictionaries permit faster access to data • Every key is separated from its value using a colon: sign • >>>dict1={‘fruit’:’apple’,’climate’:’cold’} • Print(dict1)
  • 27.
    Mutable and immutabledata types • List and dictionary are mutable datatypes • Refer page no 98 in NCERT BOOK • MEMORY ALLOCATION OF num1, num2, num1=num1+100
  • 28.
    Deciding usage ofpython data types • For storing names of students, easy to update when new admission join • Tuples use when no change ex- names of months in a year • When need uniqueness , avoid duplicacy, we use sets • When we need logical association between the key:value pair, advising to use dictionaries • Ex: mobile phone book is a good application of dictionary
  • 29.
    operators • To performmathematical or logical operation on values • Values that the operators work on are called operands • Ex: 10+num, • Value is 10 • Variable num operands and the + sign is an operator
  • 30.
    Arithmetic operators RELATIONAL OPERATORS assignmentoperators logical operators identity operators membership operator •Pg no 100 to 104 in NCERT BOOK to be work out in lab
  • 31.
    expression • Combination ofconstants, variables and operators • Always evaluates a value • A value or variable is also considered as an expression but a standalone operator is not an expression • Precedence Of expression refer pg 105 in NCERT
  • 32.
    STATEMENT • IN PYTHON,A STATEMENT IS A UNIT OF CODE THAT THE PYTHON INTERPRETER CAN EXECUTE PG NO 106 IN NCERT BOOK
  • 33.
    INPUT, OUTPUT • Itaccepts all user input as string • Input([prompt]) • Input function terminated by pressing enter key
  • 34.
    Type conversion • Pgno 108,109 in NCERT BOOK • IMPLICIT , EXPLICIT CONVERSION
  • 35.
    DEBUGGING • SYNTAX ERRORS •LOGICAL ERRORS • RUNTIME ERRORS
  • 36.