SlideShare a Scribd company logo
Python Tutorial
For Beginners
对
2015-11-20
http://pqx.ee/
Intro
时
Python
/ˈpaɪθɑːn/ in us
or
/ˈpaɪθən/ in uk
Created By
Guido van Rossum
in 1989
- 1989 快以可
⽣生起 快 “ ”
- ABC 快 ⼤大
perl lisp
-
Monty Python's Flying Circus
BBC 来
Python教程 / Python tutorial
Features and philosophy
• 了 了
• 了 中⼀一 了
• ( )
• 著
• ( & )
Language Features
• Beautiful is better than ugly
• Explicit is better than implicit
• Simple is better than complex
• Complex is better than complicated
• Readability counts
The Zen of Python
there should be one
and preferably only one
obvious way to do it
快
• 和
• 发好
batteries included
快
• GUI
•
•
Python教程 / Python tutorial
为过成
“ ⾃自” “ 上” “ ”
Use
• Web Web
• Scipy Numpy
• 有 (google TensorFlow)
• GUI PyQT wxWorks
• ( perl bash)
•
Python 也
Python
Raspberry Pi python GPIO
Pi python
quick start
Installation /
• brew install python
• apt-get install python
• yum install python
• … also, binary Installer for Windows
Hello World
print “hello world”
• Just as simple as
Interrupter / 能
能 evaluate
能
有
有
能
* python
能
能
run python code /
$ python helloWorld.py
• python 有
• CPython • IPython
• PyPy
• IronPyton
• Jython
run python code /
• REPL 也
$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on
darwin
Type "help", "copyright", "credits" or "license" for more
information.
>>> print "hello world"
hello world
(Read-Eval-Print Loop)
Mathematics /
+, -, *, /, //, %, **
出 (3.5 ) @
==, >, <, >=, <=, !=
and, or, not
=, +=, -=, *=, /=, %=
variables /
x = 1
x = ‘hello world!’
• 了 快
•
• 好
Mathematics /
• (++) 不(--)
x = 3
x += 1
x -= 2
indentation /
if x >= 60:
print ‘passed!’
else:
print ‘failed!’
• { }
python
• 快
•
• 没
多
• ...
comments /
# comments in single line
•
•
'''comments in multi line
line 2
line 3
'''
conditions /
if x >= 90:
print ‘A’
elif x >= 75:
print ‘B’
elif x >= 60:
print ‘C’
else:
print ‘D’
• if else elif
conditions /
switch !!!
成if... elif... elif... else
loops /
x = 0
while(x<100):
x = 1
print x
• while
loops /
for i in range(100):
print i
• for..in..
loops /
• continue break
(c java )
x = 0
while True:
x = x + 1
if x > 100:
break
loops /
• while for..in..
• do..while
• until
• goto
data structures
numbers /
• int
• float
• complex
str /
• 好
• % format
•
list /
•
• 的
• (List comprehensions)
dict / 都( )
•
• 的
tuple / 个
• 快 都 key
• list ,
• 新
set / 是
• 新 list
>>> set([1, 2, 3, 4, 1, 2])
set([1, 2, 3, 4])
bool /
• True / False
• python :
None
• False
•
• int
• float
• complex
Mutable Immutable
• str
• list
• set
• dict
• tuple
•
functions
function /
• 快 None
def square(x):
return x*x
• 要
快 快
def pow(x, y=2):
return x**y
好 在
• 好 在
pow(y=3, x=2)
• *
def square_sum(*values):
s = 0
for i in values:
s += i*i
return s
( )
• * *
def print_values(**values):
for k in values:
print ‘%s => %s’ % (k, values[k])
class and objects
了
class / 了 好
class Animal():
def __init__(self, name):
self.name = name
def sayHi(self):
print self.name, 'says Hi!'
builtin method / 要
• __init__
• __del__
• __repr__
• __str__
• __unicode__
• 会
•
__x _classname__x
class Cat(Animal):
def __init__(self, name='kitty'):
self.name = name
def sayHi(self):
print ‘hello %s mio!’ % self.name
了
• 了
•
• 1+2 (1).__add__(2)
•
module and import
module /
• 最
• sys.modules
开
开 PYTHONPATH
开 要
import /
• 快
• (__import__)
• execfile
input and output
下 下
IO
• raw_input (python3 input)
• sys.stdin sys.stdout
• print
• open
• read
• write
json
• dumps
• loads
advanced features
• lambda ( )
•
• map reduce filter
•
—
• dir hasattr getattr setattr
• eval exec
• locals globals
要
• 成 __doc__ __name__ __file__
• : __dict__ __class__
• 了: __doc__ __module__ __dict__
__bases__
• yield 有
• 有
• 了
• C/C++ 分 python
summary
• 了 了
• 了 中⼀一 了
• ( )
• 著
• ( & )
Features /
https://github.com/vinta/awesome-python
去 C
JAVA C#
Python !!!

More Related Content

PDF
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
PDF
Chapter 0 Python Overview (Python Programming Lecture)
PDF
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
PDF
Python tutorial
PDF
Python Workshop
PPT
Python - Introduction
PDF
Python made easy
PDF
Python Tutorial
Advanced Python Tutorial | Learn Advanced Python Concepts | Python Programmin...
Chapter 0 Python Overview (Python Programming Lecture)
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python tutorial
Python Workshop
Python - Introduction
Python made easy
Python Tutorial

What's hot (20)

PDF
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
PPT
Python ppt
PDF
Python basics_ part1
PPT
Introduction to Python
PPTX
Python Seminar PPT
ODP
Python and Machine Learning
PPTX
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
PDF
Python Workshop
PDF
Python - An Introduction
PPTX
Python basics
PPTX
Basic Python Programming: Part 01 and Part 02
PDF
Python Foundation – A programmer's introduction to Python concepts & style
PDF
The Benefits of Type Hints
ODP
Python Presentation
PPTX
Python 101: Python for Absolute Beginners (PyTexas 2014)
PDF
pyconjp2015_talk_Translation of Python Program__
PDF
Introduction to Python Pandas for Data Analytics
DOCX
PYTHON NOTES
 
ODP
Python_in_Detail
PPTX
Learn python – for beginners
Python Tutorial | Python Tutorial for Beginners | Python Training | Edureka
Python ppt
Python basics_ part1
Introduction to Python
Python Seminar PPT
Python and Machine Learning
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Python Workshop
Python - An Introduction
Python basics
Basic Python Programming: Part 01 and Part 02
Python Foundation – A programmer's introduction to Python concepts & style
The Benefits of Type Hints
Python Presentation
Python 101: Python for Absolute Beginners (PyTexas 2014)
pyconjp2015_talk_Translation of Python Program__
Introduction to Python Pandas for Data Analytics
PYTHON NOTES
 
Python_in_Detail
Learn python – for beginners
Ad

Viewers also liked (20)

PPTX
Basics of Python programming (part 2)
PPTX
Introduction to the basics of Python programming (part 3)
PPTX
Introduction to the basics of Python programming (part 1)
PDF
Python简明教程
PDF
AMD Radeon R7 Series SSD
PDF
BIOS and Secure Boot Attacks Uncovered
PPSX
07. Mainboard (System Board, Motherboard)
PDF
Intel ssd dc data center family for PCIe
PPTX
thunderbolt interface
PPTX
Automation Testing
PDF
WiGig PPT
PDF
Moving to PCI Express based SSD with NVM Express
PPTX
System Booting Process overview
PPTX
Python Tutorial Part 1
PPTX
booting steps of a computer
PPTX
Python Tutorial Part 2
PDF
AVR_Course_Day1 basic electronics
PPTX
Introduction to Motherboard
PDF
My Career profile
Basics of Python programming (part 2)
Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 1)
Python简明教程
AMD Radeon R7 Series SSD
BIOS and Secure Boot Attacks Uncovered
07. Mainboard (System Board, Motherboard)
Intel ssd dc data center family for PCIe
thunderbolt interface
Automation Testing
WiGig PPT
Moving to PCI Express based SSD with NVM Express
System Booting Process overview
Python Tutorial Part 1
booting steps of a computer
Python Tutorial Part 2
AVR_Course_Day1 basic electronics
Introduction to Motherboard
My Career profile
Ad

Similar to Python教程 / Python tutorial (20)

PDF
Python于Web 2.0网站的应用 - QCon Beijing 2010
PPT
Fabric
PDF
Python高级编程(二)
PDF
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
PPTX
Python in easy way It includes different data type
PPTX
Python programming basic Presentation.pptx
KEY
Google Go Overview
PPTX
Go from a PHP Perspective
PDF
龍華大學前端技術分享 Part1
KEY
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
PDF
Learning Python from Data
KEY
State of Python (2010)
PDF
Migrating from matlab to python
PPTX
C++_Programming_Presentation .pptx
PPTX
¡El mejor lenguaje para automatizar pruebas!
PDF
CPAN 模組二三事
PPTX
Python programming
PDF
Unleash your inner console cowboy
PDF
DIG1108C Lesson3 Fall 2014
Python于Web 2.0网站的应用 - QCon Beijing 2010
Fabric
Python高级编程(二)
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
Python in easy way It includes different data type
Python programming basic Presentation.pptx
Google Go Overview
Go from a PHP Perspective
龍華大學前端技術分享 Part1
アジャイルな開発をチームで やってみた(2010年版) - PHP Matsuri編
Learning Python from Data
State of Python (2010)
Migrating from matlab to python
C++_Programming_Presentation .pptx
¡El mejor lenguaje para automatizar pruebas!
CPAN 模組二三事
Python programming
Unleash your inner console cowboy
DIG1108C Lesson3 Fall 2014

Recently uploaded (20)

PDF
Top Generative AI Tools for Patent Drafting in 2025.pdf
PDF
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
PPTX
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PDF
REPORT: Heating appliances market in Poland 2024
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
PDF
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PDF
Google’s NotebookLM Unveils Video Overviews
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Dell Pro 14 Plus: Be better prepared for what’s coming
Top Generative AI Tools for Patent Drafting in 2025.pdf
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
madgavkar20181017ppt McKinsey Presentation.pdf
Reimagining Insurance: Connected Data for Confident Decisions.pdf
REPORT: Heating appliances market in Poland 2024
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
KodekX | Application Modernization Development
NewMind AI Weekly Chronicles - August'25 Week I
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Enable Enterprise-Ready Security on IBM i Systems.pdf
NewMind AI Monthly Chronicles - July 2025
Smarter Business Operations Powered by IoT Remote Monitoring
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
Google’s NotebookLM Unveils Video Overviews
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Dell Pro 14 Plus: Be better prepared for what’s coming

Python教程 / Python tutorial