SlideShare a Scribd company logo
Learn Python
By
Ajay Kumar
Overview
• History
• Installing & Running Python
• Names & Assignment
• Sequences types: Lists, Tuples, and Strings
• Mutability
Brief History of Python
• Invented in the Netherlands, early 90s by Guido van Rossum
• Named after Monty Python
• Open sourced from the beginning
• Considered a scripting language, but is much more
• Scalable, object oriented and functional from the beginning
• Used by Google from the beginning
• Increasingly popular
Python Creator
“Python is an experiment in
how much freedom program-
mers need. Too much
freedom and nobody can read
another's code; too little and
expressive-ness is
endangered.”
- Guido van Rossum
Applications of Python
• Web Development
• Game Development
• Machine Learning and Artificial Intelligence
• Data Science and Data Visualization
• Desktop GUI
• Web Scraping Applications
• Business Applications
• Audio and Video Applications
• CAD Applications
• Embedded Applications
Running Python
• Visit www.python.org
Python script
• When you call a python program from the command line the
interpreter evaluates each expression in the file
• Familiar mechanisms are used to provide command line arguments
and/or redirect input and output
• Python also has mechanisms to allow a python program to act both
as a script and as a module to be imported and used by another
python program
The basics of
Python
Python code sample
x = 34 - 23 # A comment.
y = “Hello” # Another one.
z = 3.45
if z == 3.45 or y == “Hello”:
x = x + 1
y = y + “ World” # String concat.
print x
print y
Understanding the code
 Indentation matters to code meaning
• Block structure indicated by indentation
 First assignment to a variable creates it
• Variable types don’t need to be declared.
• Python figures out the variable types on its own.
 Assignment is = and comparison is ==
 For numbers + - * / % are as expected
• Special use of + for string concatenation and % for string formatting (as in C’s printf)
 Logical operators are words (and, or, not) not symbols
 The basic printing command is print
Basic Datatypes
 Integers (default for numbers)
z = 5 / 2 # Answer 2, integer division
 Floats
x = 3.456
 Strings
• Can use “” or ‘’ to specify with “abc” == ‘abc’
• Unmatched can occur within the string: “matt’s”
• Use triple double-quotes for multi-line strings or strings than contain
both ‘ and “ inside of them:
“““a‘b“c”””
Whitespaces
Whitespace is meaningful in Python: especially indentation and
placement of newlines
•Use a newline to end a line of code
Use  when must go to next line prematurely
•No braces {} to mark blocks of code, use consistent indentation
instead
• First line with less indentation is outside of the block
• First line with more indentation starts a nested block
•Colons start of a new block in many constructs, e.g. function
definitions, then clauses
The + operator
The + operator produces a new tuple, list, or string whose value is the
concatenation of its arguments.
>>> (1, 2, 3) + (4, 5, 6)
(1, 2, 3, 4, 5, 6)
>>> [1, 2, 3] + [4, 5, 6]
[1, 2, 3, 4, 5, 6]
>>> “Hello” + “ ” + “World”
‘Hello World’
The * Operator
 The * operator produces a new tuple, list, or string that “repeats” the
original content.
>>> (1, 2, 3) * 3
(1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> [1, 2, 3] * 3
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> “Hello” * 3
‘HelloHelloHello’

More Related Content

What's hot (20)

PDF
An Introduction to Python Programming
Morteza Zakeri
 
PPTX
python classes in thane
faizrashid1995
 
PPTX
Python programming introduction
Siddique Ibrahim
 
PPT
More Pointers and Arrays
emartinez.romero
 
PPTX
Python basics
Jyoti shukla
 
PPTX
Logic programming in python
Pierre Carbonnelle
 
PPTX
Phython Programming Language
R.h. Himel
 
PPTX
Python Programming
shahid sultan
 
PPTX
What is Python? An overview of Python for science.
Nicholas Pringle
 
PDF
Python quick guide1
Kanchilug
 
PPTX
1. python programming
sreeLekha51
 
PDF
NTUT Information Security Homework 1
dennysora
 
PPTX
Loops in Python
Arockia Abins
 
PPT
Intro to Python
primeteacher32
 
PPT
Python Introduction
Mohammad Javad Beheshtian
 
PPTX
Introduction to python for Beginners
Sujith Kumar
 
PPTX
Python presentation by Monu Sharma
Mayank Sharma
 
PPTX
LZ77 and LZ78 Compression Algorithms
Mustafa GÖKÇE
 
PPTX
Python Basics
Pooja B S
 
An Introduction to Python Programming
Morteza Zakeri
 
python classes in thane
faizrashid1995
 
Python programming introduction
Siddique Ibrahim
 
More Pointers and Arrays
emartinez.romero
 
Python basics
Jyoti shukla
 
Logic programming in python
Pierre Carbonnelle
 
Phython Programming Language
R.h. Himel
 
Python Programming
shahid sultan
 
What is Python? An overview of Python for science.
Nicholas Pringle
 
Python quick guide1
Kanchilug
 
1. python programming
sreeLekha51
 
NTUT Information Security Homework 1
dennysora
 
Loops in Python
Arockia Abins
 
Intro to Python
primeteacher32
 
Python Introduction
Mohammad Javad Beheshtian
 
Introduction to python for Beginners
Sujith Kumar
 
Python presentation by Monu Sharma
Mayank Sharma
 
LZ77 and LZ78 Compression Algorithms
Mustafa GÖKÇE
 
Python Basics
Pooja B S
 

Similar to Demo learn python (20)

PDF
Sessisgytcfgggggggggggggggggggggggggggggggg
pawankamal3
 
PPTX
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
sangeeta borde
 
PPTX
python presntation 2.pptx
Arpittripathi45
 
PPTX
1-Introduction to Python, features of python, history of python(1).pptx
MAHESWARIS55
 
PDF
ppt_pspp.pdf
ShereenAhmedMohamed
 
PPT
Python - Module 1.ppt
jaba kumar
 
PPTX
cupdf.com_python-seminar-ppt.pptx.........
ansuljoshi8456
 
PPT
Getting started in Python presentation by Laban K
GDSCKYAMBOGO
 
PPTX
Python Traning presentation
Nimrita Koul
 
PPTX
Learn about Python power point presentation
omsumukh85
 
PPTX
Python Introduction
Punithavel Ramani
 
PPT
Python ppt
Mohita Pandey
 
PPTX
Python 3.pptx
HarishParthasarathy4
 
PPTX
lecture 2.pptx
Anonymous9etQKwW
 
PPTX
Python
Gagandeep Nanda
 
PPTX
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
PDF
python-160403194316.pdf
gmadhu8
 
PDF
Pythonintro
Hardik Malhotra
 
Sessisgytcfgggggggggggggggggggggggggggggggg
pawankamal3
 
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
sangeeta borde
 
python presntation 2.pptx
Arpittripathi45
 
1-Introduction to Python, features of python, history of python(1).pptx
MAHESWARIS55
 
ppt_pspp.pdf
ShereenAhmedMohamed
 
Python - Module 1.ppt
jaba kumar
 
cupdf.com_python-seminar-ppt.pptx.........
ansuljoshi8456
 
Getting started in Python presentation by Laban K
GDSCKYAMBOGO
 
Python Traning presentation
Nimrita Koul
 
Learn about Python power point presentation
omsumukh85
 
Python Introduction
Punithavel Ramani
 
Python ppt
Mohita Pandey
 
Python 3.pptx
HarishParthasarathy4
 
lecture 2.pptx
Anonymous9etQKwW
 
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
python-160403194316.pdf
gmadhu8
 
Pythonintro
Hardik Malhotra
 
Ad

More from DIT University, Dehradun (6)

PDF
Elements in Multimedia Systems for BTech
DIT University, Dehradun
 
PDF
Lecture 1 Multimedia System for BTech CSE
DIT University, Dehradun
 
PPTX
R Data Structure.pptx
DIT University, Dehradun
 
DOCX
Course era financial aid
DIT University, Dehradun
 
PPTX
Email etiquette
DIT University, Dehradun
 
PDF
Function lecture
DIT University, Dehradun
 
Elements in Multimedia Systems for BTech
DIT University, Dehradun
 
Lecture 1 Multimedia System for BTech CSE
DIT University, Dehradun
 
R Data Structure.pptx
DIT University, Dehradun
 
Course era financial aid
DIT University, Dehradun
 
Email etiquette
DIT University, Dehradun
 
Function lecture
DIT University, Dehradun
 
Ad

Recently uploaded (20)

PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 

Demo learn python

  • 2. Overview • History • Installing & Running Python • Names & Assignment • Sequences types: Lists, Tuples, and Strings • Mutability
  • 3. Brief History of Python • Invented in the Netherlands, early 90s by Guido van Rossum • Named after Monty Python • Open sourced from the beginning • Considered a scripting language, but is much more • Scalable, object oriented and functional from the beginning • Used by Google from the beginning • Increasingly popular
  • 4. Python Creator “Python is an experiment in how much freedom program- mers need. Too much freedom and nobody can read another's code; too little and expressive-ness is endangered.” - Guido van Rossum
  • 5. Applications of Python • Web Development • Game Development • Machine Learning and Artificial Intelligence • Data Science and Data Visualization • Desktop GUI • Web Scraping Applications • Business Applications • Audio and Video Applications • CAD Applications • Embedded Applications
  • 6. Running Python • Visit www.python.org
  • 7. Python script • When you call a python program from the command line the interpreter evaluates each expression in the file • Familiar mechanisms are used to provide command line arguments and/or redirect input and output • Python also has mechanisms to allow a python program to act both as a script and as a module to be imported and used by another python program
  • 9. Python code sample x = 34 - 23 # A comment. y = “Hello” # Another one. z = 3.45 if z == 3.45 or y == “Hello”: x = x + 1 y = y + “ World” # String concat. print x print y
  • 10. Understanding the code  Indentation matters to code meaning • Block structure indicated by indentation  First assignment to a variable creates it • Variable types don’t need to be declared. • Python figures out the variable types on its own.  Assignment is = and comparison is ==  For numbers + - * / % are as expected • Special use of + for string concatenation and % for string formatting (as in C’s printf)  Logical operators are words (and, or, not) not symbols  The basic printing command is print
  • 11. Basic Datatypes  Integers (default for numbers) z = 5 / 2 # Answer 2, integer division  Floats x = 3.456  Strings • Can use “” or ‘’ to specify with “abc” == ‘abc’ • Unmatched can occur within the string: “matt’s” • Use triple double-quotes for multi-line strings or strings than contain both ‘ and “ inside of them: “““a‘b“c”””
  • 12. Whitespaces Whitespace is meaningful in Python: especially indentation and placement of newlines •Use a newline to end a line of code Use when must go to next line prematurely •No braces {} to mark blocks of code, use consistent indentation instead • First line with less indentation is outside of the block • First line with more indentation starts a nested block •Colons start of a new block in many constructs, e.g. function definitions, then clauses
  • 13. The + operator The + operator produces a new tuple, list, or string whose value is the concatenation of its arguments. >>> (1, 2, 3) + (4, 5, 6) (1, 2, 3, 4, 5, 6) >>> [1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6] >>> “Hello” + “ ” + “World” ‘Hello World’
  • 14. The * Operator  The * operator produces a new tuple, list, or string that “repeats” the original content. >>> (1, 2, 3) * 3 (1, 2, 3, 1, 2, 3, 1, 2, 3) >>> [1, 2, 3] * 3 [1, 2, 3, 1, 2, 3, 1, 2, 3] >>> “Hello” * 3 ‘HelloHelloHello’