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
Presentation on python
PPTX
Introduction to 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
Presentation on python
Introduction to 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)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Pre independence Education in Inndia.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Microbial disease of the cardiovascular and lymphatic systems
human mycosis Human fungal infections are called human mycosis..pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Anesthesia in Laparoscopic Surgery in India
PPH.pptx obstetrics and gynecology in nursing
Final Presentation General Medicine 03-08-2024.pptx
O7-L3 Supply Chain Operations - ICLT Program
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Abdominal Access Techniques with Prof. Dr. R K Mishra
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
102 student loan defaulters named and shamed – Is someone you know on the list?
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pre independence Education in Inndia.pdf
Computing-Curriculum for Schools in Ghana
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Complications of Minimal Access Surgery at WLH
Microbial disease of the cardiovascular and lymphatic systems

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’