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

PPTX
Introduction to python
PPTX
Presentation on python
PDF
Python cheat-sheet
PDF
Python Training Topics
PPTX
Introduction to Python Part-1
PPTX
Python Tutorial Part 2
PDF
CNIT 127 Ch 4: Introduction to format string bugs
PPT
Introduction to phython programming
Introduction to python
Presentation on python
Python cheat-sheet
Python Training Topics
Introduction to Python Part-1
Python Tutorial Part 2
CNIT 127 Ch 4: Introduction to format string bugs
Introduction to phython programming

What's hot (20)

PDF
An Introduction to Python Programming
PPTX
python classes in thane
PPTX
Python programming introduction
PPT
More Pointers and Arrays
PPTX
Python basics
PPTX
Logic programming in python
PPTX
Phython Programming Language
PPTX
Python Programming
PPTX
What is Python? An overview of Python for science.
PDF
Python quick guide1
PPTX
1. python programming
PDF
NTUT Information Security Homework 1
PPTX
Loops in Python
PPT
Intro to Python
PPT
Python Introduction
PPTX
Introduction to python for Beginners
PPTX
Python presentation by Monu Sharma
PPTX
LZ77 and LZ78 Compression Algorithms
PPTX
Python Basics
An Introduction to Python Programming
python classes in thane
Python programming introduction
More Pointers and Arrays
Python basics
Logic programming in python
Phython Programming Language
Python Programming
What is Python? An overview of Python for science.
Python quick guide1
1. python programming
NTUT Information Security Homework 1
Loops in Python
Intro to Python
Python Introduction
Introduction to python for Beginners
Python presentation by Monu Sharma
LZ77 and LZ78 Compression Algorithms
Python Basics
Ad

Similar to Demo learn python (20)

PDF
Sessisgytcfgggggggggggggggggggggggggggggggg
PPTX
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
PPTX
python presntation 2.pptx
PPTX
1-Introduction to Python, features of python, history of python(1).pptx
PDF
ppt_pspp.pdf
PPT
Python - Module 1.ppt
PPTX
cupdf.com_python-seminar-ppt.pptx.........
PPT
Getting started in Python presentation by Laban K
PPTX
Python Traning presentation
PPTX
Learn about Python power point presentation
PPTX
Python Introduction
PPT
Python ppt
PPTX
Python 3.pptx
PPTX
lecture 2.pptx
PPTX
PPTX
INTRODUCTION TO PYTHON.pptx
PDF
python-160403194316.pdf
PDF
Pythonintro
Sessisgytcfgggggggggggggggggggggggggggggggg
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
python presntation 2.pptx
1-Introduction to Python, features of python, history of python(1).pptx
ppt_pspp.pdf
Python - Module 1.ppt
cupdf.com_python-seminar-ppt.pptx.........
Getting started in Python presentation by Laban K
Python Traning presentation
Learn about Python power point presentation
Python Introduction
Python ppt
Python 3.pptx
lecture 2.pptx
INTRODUCTION TO PYTHON.pptx
python-160403194316.pdf
Pythonintro
Ad

More from DIT University, Dehradun (6)

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

Recently uploaded (20)

PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PPTX
Strengthening open access through collaboration: building connections with OP...
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
Landforms and landscapes data surprise preview
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PDF
Sunset Boulevard Student Revision Booklet
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
Congenital Hypothyroidism pptx
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
The Final Stretch: How to Release a Game and Not Die in the Process.
Strengthening open access through collaboration: building connections with OP...
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Landforms and landscapes data surprise preview
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
vedic maths in python:unleasing ancient wisdom with modern code
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
Sunset Boulevard Student Revision Booklet
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Skill Development Program For Physiotherapy Students by SRY.pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Open Quiz Monsoon Mind Game Prelims.pptx
Congenital Hypothyroidism pptx
Introduction and Scope of Bichemistry.pptx
How to Manage Bill Control Policy in Odoo 18
Information Texts_Infographic on Forgetting Curve.pptx
Revamp in MTO Odoo 18 Inventory - Odoo Slides

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’