6. Top Language in TIOBE
Position
May 2013
Position
May 2012
Delta in
Position
Programming Language
1
2
3
4
5
6
7
8
9
10
1
2
4
3
5
6
7
8
9
11
=
=
↑
↓
=
=
=
=
=
↑
C
Java
Objective-C
C++
C#
PHP
Visual Basic
Python
Perl
Ruby
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
7. Top Languages in Github
Javascript
21%
Ruby
12%
Java
8%
Python
8%
Shell
8%
PHP
7%
C
6%
C++
5%
Perl
4%
Objective-C
3%
0%
5%
10%
15%
20%
25%
https://github.com/languages
8. Top Languages in Github
Javascript
21%
Ruby
12%
Java
8%
Python
8%
Shell
8%
PHP
7%
C
6%
C++
5%
Perl
4%
Objective-C
3%
0%
5%
10%
15%
20%
25%
https://github.com/languages
29. Zen of Python
one
There
temptation to guess. and refuse
In --obviousbe
Unless
Errors
Althoughcasesbetter
breakis betternever pass Peters
Specialfacebetter may beats
ReadabilityPython,tonested.
Sparse explicitly silenced.
FlatZenshould“”ambiguity,silently.
Complexispracticality dense. obvious
Simpleshouldofaren'tthanit. enough
Explicitisrules. than complex.
Beautifulisthisthanthan implicit.the at
The importbetterone--docomplicated. only
>>>thethe-iccounts.byspecialpurity. to
$ pythonofisbetterthanTimugly.
that way
not preferably
be
first
one
There
temptation to way
In --obvious guess. and preferably
Unless casesyou're
Errors betternever Dutch.refuse
Althoughisrules. may beats
breakisfacebetter topass Peters
Specialexplicitlythan dense.
ReadabilityPython,silenced.
Sparseunlessofaren'tnested. obvious
FlatZenshouldbeambiguity,silently.
Complexisthatbetter thanit. enough
Simpleshouldcounts.than implicit.the at
Explicitofbetterone-- complex.
Beautifulpracticalitydocomplicated. only
The importisbetterthanTimugly.
>>>thetheisthisthanbyspecialpurity. to
not be
Now
first
one is cases than
There
temptationrules.
In --obvious way may and preferably
Unless betterguess. beats
Errors better never Dutch.refuse
Althoughisbetterone-- dense.
breakisfacetoyou're pass Peters
Specialexplicitly tonested.
Readabilitybetterthan complex.
Sparseunlessofaren'tthanit. obvious
FlatZenshouldbethannever.silently.
Complexisthatbetterthan implicit.the
Simpleshouldcounts.bydocomplicated. at
Explicitofisbettersilenced. enough only
Beautifulpracticalityspecialpurity. to
ThethetheisPython,thanTimugly.
ambiguity, be
not
Now
first
one is cases thanmay not preferably
There
temptationbetterone-- andsilently.
In the better way to beats
Unless face
Errorsunlessofguess. dense.
Althoughbetternever Dutch.refuse
breakisexplicitly silenced.
Specialshould aren'tpassbetter
Readabilitytoyou're nested. obvious
Sparseshouldcounts. thanit. enough
Flat--obviousbethannever.ugly.
Complexisthatbetterthan implicit.the at
Simplethepracticalitydocomplicated. only
Explicitisisbetterthancomplex. than *right*
Beautifulisbetterthanspecialpurity. to
never ambiguity, be
rules. often
is
now.
Now
first
one is cases thanmay not preferably
There
temptationbetterone-- andsilently.
In the better way to beats
Unless face
Errorsunlessofguess. dense.
Althoughbetternever Dutch.refuse
breakisexplicitly silenced.
Specialshould aren'tpassbetter
Readabilitytoyou're nested. obvious
Sparseshouldcounts. thanit. enough
Flat--obviousbethannever.ugly.
Complexisthatbetterthan implicit.the at
Simplethepracticalitydocomplicated. only
Explicitisisbetterthancomplex. than *right*
Beautifulisbetterthanspecialpurity. to
never ambiguity, be
rules. often
is
If
now.
Now
first
one is cases thanoften
There implementation isbetter
temptationrules. may not preferably
In the better way to andhard than
Unless face ofguess. beats
Errorsunlesscounts. Dutch.refuse
Althoughbetternever passit.
breakisexplicitly silenced.
Specialshould aren'tnested. obvious
Readabilitytoyou'renever.silently.
Sparseshouldbetterthandense. enough at
Flat--obviousbethanthan implicit.explain,
Complexispracticality complex.to the only
Simpletheisbetterthandocomplicated. *right*
Explicitisbetterone--specialpurity. to
never is
that ambiguity, be
it's
If
now.
Now
first
one is bad idea. may isbetter
Therea implementation not preferably
temptationrules. to andhard than
In the better way silenced.
Unless faceto guess. beats
Errorsunlessofnever
Althoughisbetterone-- dense.
breakisexplicitly thancomplex.to explain,
Specialshould aren'tDutch.refuse the
Readabilitybetterthandocomplicated.
Sparseshouldcounts. passit. obvious at
Flat--obviousyou're nested. enough only
Complexisthatbethannever.silently. *right*
Simplethepracticalityspecialpurity. to
cases ambiguity, be
betterthanoften
never is
it's
If
now.
Now
first bad idea. may
one is implementation isbetter
Therea better way to noteasy
temptationrules. silenced.
In the faceto guess. andhard than
Unlessunlessofnever
Errorsshouldcounts. Dutch.refuse explain,
Althoughisbetterone-- beats
breakisexplicitly thandense. to the
Specialshould aren'tpassit. obvious
Readabilitybetterthandocomplicated. at
Sparsethethatyou're nested. enough only
Flat--obviousbethannever.silently. *right*
Complexispracticalityspecialpurity. to
cases ambiguity, preferably
betterthanoften
never is
be
it
it's
If
now.
Now is badrules. may
first implementation is preferably
onemay better thanto noteasy
Therea faceidea. silenced.
temptationbetterone-- andhard than
In the explicitlyidea.beats
Unlessunlessofwaythan dense.
Errorsshouldcounts.
Althoughbetterguess. do betterto explain,
breakisshould never Dutch.refuse the
Specialisthat aren'tpassit. obvious at
Readabilitytoyou're nested. enough only
Sparsethepracticalityspecialpurity. *right*
Flat--obviousbethannever.silently. to
benever ambiguity, be
cases is often
a good
Namespacesaare is often
it
it's
If
now.is badrules. may
Now --obvious thanto is
first implementation not be
onemay better way silenced.
There faceidea. idea.andeasy than
temptationbetterone-- beats
In the explicitlythan dense. obvious
Unless should guess. do betterto idea
Errorsunlessofnever Dutch.preferably
Althoughcases aren'tpassit.great explain,
breakashouldcounts.honkingrefuse the at
Specialisthatyou'renever.hardenough only
Readabilitytobeambiguity,silently. *right*
Sparsethepracticalityspecialpurity. to-benever one
good
let's bad good often
Namespacesaareof may
it
it's
If
now.is implementation is
Now --obvious thanto not be
first better way silenced.
onemay faceidea. those!
There explicitlyidea.andeasy than
temptationrules.one-- beats obvious
In thedo that guess. do betterto idea
Unlessunlessofnever Dutch.preferably
Errorsshouldcounts.honkingrefuse explain,
Althoughcases aren'tpassit.great the at
breakathepracticalityspecialpurity. only
Specialshouldyou'renever.hardenough *right*
Readabilitytobeambiguity,silently. to-benever is
more one
>>>
let's bad areof often
Namespacesaidea. may is
it
it's
If
now.is implementation not
Now --obvious thanto and be
first better way silenced.
onemay faceto guess.Dutch.preferably
There explicitlythose! easy than
temptationrules. idea.beats obvious
In thedo that neverhonkingrefuse idea
Unlessunlessgoodone--do betterto explain,
Errorsshouldofaren'tpassit.great the at
Althoughcasesyou'renever.hardenough only
breakathepracticalityspecialpurity. *right*
Specialshouldbeambiguity,silently. to-benever is
more one
35. Python 2.x
Python 3.x
2.7.x is the latest version
under development
more 3-party library
2to3.py
built-in on many OS
more supported unicode
the past in someday
the future in someday
41. Environment
For Windows User,
Download From
http://www.python.org/download/
if you want to launch Python in command line,
add the path of Python binary file into PATH variable.
48. Check Version of Python
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
49. Check Version of Python
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
52. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
53. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
prompt
54. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
prompt
means that your turn!
57. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>>
58. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
59. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>>
60. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>> “Hello World”
61. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>> “Hello World”
‘Hello World’
>>>
62. Interactive Shell
$ python
Python 2.7.5 (default, May 20 2013,
23:41:46)
[GCC 4.2.1 Compatible Apple LLVM 4.2
(clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or
"license" for more information.
>>> 1 + 2 + 3
6
>>> “Hello World”
‘Hello World’
>>> x = 100
63. Interactive Shell
Python 2.7.5 (default, May 20 2013,
$ python
23:41:46)
Python 2.7.5 (default, May 20 2013,
[GCC 4.2.1
23:41:46) Compatible Apple LLVM 4.2
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
"license" for more information.
Type "help", "copyright", "credits" or
>>> 1 + 2 + 3
"license" for more information.
6
>>> 1 + 2 + 3
>>> “Hello World”
6
‘Hello World’
>>> “Hello World”
>>> x
‘Hello=World’
100
>>> x = 100
64. Interactive Shell
Python 2.7.5 (default, May 20 2013,
$ python
23:41:46)
Python 2.7.5 (default, May 20 2013,
[GCC 4.2.1
23:41:46) Compatible Apple LLVM 4.2
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
"license" for more information.
Type "help", "copyright", "credits" or
>>> 1 + 2 + 3
"license" for more information.
6
>>> 1 + 2 + 3
>>> “Hello World”
6
‘Hello World’
>>> “Hello World”
>>> x
‘Hello=World’
100
>>> x = 100
y
200
65. Interactive Shell
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
[GCC 4.2.1
23:41:46) Compatible May LLVM 4.2
Python 2.7.5 (default,Apple20 2013,
(clang-425.0.28)] on Apple
[GCC 4.2.1
23:41:46) Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits"
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2or
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>>
"license" for more information.
Type1"help",3"copyright", "credits" or
+ 2 +
6
>>> 1 + 2 + 3
"license" for more information.
6
>>> “Hello+World”
1 + 2
3
‘Hello World’
>>> “Hello World”
6
‘Hello=World’
>>> “Hello World”
x
100
>>> x
‘Hello=World’
y
200
100
>>> x = 100
y
200
66. Interactive Shell
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
[GCC 4.2.1
23:41:46) Compatible May LLVM 4.2
Python 2.7.5 (default,Apple20 2013,
(clang-425.0.28)] on Apple
[GCC 4.2.1
23:41:46) Compatibledarwin LLVM 4.2
Type "help", "copyright", "credits"
(clang-425.0.28)] on Apple
[GCC 4.2.1 Compatibledarwin LLVM 4.2or
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>>
"license" for more information.
Type1"help",3"copyright", "credits" or
+ 2 +
6
>>> 1 + 2 + 3
"license" for more information.
6
>>> “Hello+World”
1 + 2
3
‘Hello World’
>>> “Hello World”
6
‘Hello=World’
>>> “Hello World”
x
100
>>> x
‘Hello=World’
y
200
100
>>> x = y
y + 100
200
67. Interactive Shell
(clang-425.0.28)] on darwin
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
Type "help", "copyright",
[GCC 4.2.1
23:41:46) Compatible May"credits"
Python 2.7.5 (default,Apple20 2013, or
LLVM 4.2
"license"
(clang-425.0.28)] information.
[GCC 4.2.1 Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
6
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
+ 2
‘Hello 2 + 3
6
>>> 1 +World’
"license" for more information.
6
>>> “Hello+World”
x + 2
1 = 100 3
‘Hello=World’
>>> “Hello World”
6
y
200
‘Hello=World’
>>> “Hello World”
x + y
100
300 y
>>> x
‘Hello=World’
200
100
>>> x = y
y + 100
200
68. Interactive Shell
(clang-425.0.28)] on darwin
23:41:46)
Python 2.7.5 (default, May 20 2013,
$ python
Type "help", "copyright",
[GCC 4.2.1
23:41:46) Compatible May"credits"
Python 2.7.5 (default,Apple20 2013, or
LLVM 4.2
"license"
(clang-425.0.28)] information.
[GCC 4.2.1 Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
6
"license" for more information.
Type "help", "copyright", "credits" or
(clang-425.0.28)] on darwin
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
+ 2
‘Hello 2 + 3
6
>>> 1 +World’
"license" for more information.
6
>>> “Hello+World”
x + 2
1 = 100 3
‘Hello=World’
>>> “Hello World”
6
y
200
‘Hello=World’
>>> “Hello World”
x + y
100
300 y
>>> x
‘Hello=World’
200
100
>>> for y in range(5):
y + 100
x = i
200
69. Interactive Shell
Type "help", "copyright",
(clang-425.0.28)] on darwin20 2013,
23:41:46)
Python 2.7.5 (default, May"credits" or
$ python
"license"
Type "help", more information.
[GCC 4.2.1 Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python 2.7.5 (default,Apple20 2013, or
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
>>> "help", more
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
‘Hello+World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
x
2 +
6
>>> “Hello+World”
y
x + 200
1 = 100 3
2
‘Hello=World’
>>> “Hello World”
6
x
y + y
200
300 x + y
‘Hello=World’
>>> “Hello World”
100
300 x
>>> for i in
‘Hello=World’range(5):
y
200
100
... x = i
>>> for y in range(5):
y + 100
200
70. Interactive Shell
Type "help", "copyright",
(clang-425.0.28)] on darwin20 2013,
23:41:46)
Python 2.7.5 (default, May"credits" or
$ python
"license"
Type "help", more information.
[GCC 4.2.1 Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python 2.7.5 (default,Apple20 2013, or
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>>
Type "help",3"copyright", "credits"
(clang-425.0.28)] on Apple
[GCC14.2.1+Compatibledarwin LLVM 4.2or
+ 2
>>> "help", more
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
‘Hello+World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
x
2 +
6
>>> “Hello+World”
y
x + 200
1 = 100 3
2
‘Hello=World’
>>> “Hello World”
6
x
y + y
200
300 x + y
‘Hello=World’
>>> “Hello World”
100
300 x
>>> for i in
‘Hello=World’range(5):
y
200
100
... x = y in i
>>> for printrange(5):
y + i
200
100
71. Interactive Shell
"license"
Type "help", more information.
(clang-425.0.28)] on darwin
23:41:46)
Python 2.7.5 "copyright", 20 2013,
$ python for(default, May"credits" or
>>>
"license"
Type "help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
2
6
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>> "help",3"copyright", "credits"
Type14.2.1 Compatible Apple
(clang-425.0.28)]
[GCC“Hello+World” on darwin LLVM 4.2or
+ 2
‘Hello World’
>>> "help", more
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
x + 100
2
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
... y
300 x
>>> for print i
‘Hello=World’range(5):
i in
200
100
... x = y in i
>>> for printrange(5):
y + i
200
100
72. Interactive Shell
>>>
"license"
Typey"help",
(clang-425.0.28)] information.
23:41:46) for moreon darwin
Python=2.7.5 "copyright", 20 2013,
$ python200 (default, May"credits" or
>>>
"license"
Typex"help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
y
2
300
6
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>> 14.2.1 Compatible
Typefor i +World”
(clang-425.0.28)] on darwin
[GCC“Helloin3range(5):Apple LLVM 4.2or
"help", "copyright", "credits"
+ 2
...
‘Hello World’ more
>>> "help", i
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
print
... x + 100
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
0
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
1
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
3
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
4
... y
300 x
>>> for print i
‘Hello=World’range(5):
i in
200
100
... x = y in i
>>> for printrange(5):
y + i
200
100
73. Interactive Shell
>>>
"license"
Typey"help",
(clang-425.0.28)] information.
23:41:46) for moreon darwin
Python=2.7.5 "copyright", 20 2013,
$ python200 (default, May"credits" or
>>>
"license"
Typex"help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
y
2
300
6
>>>
"license"
(clang-425.0.28)] information.
[GCC14.2.1+Compatible Apple
23:41:46) for moreon darwin LLVM 4.2
+ 2
3
6
>>> 14.2.1 Compatible
Typefor i +World”
(clang-425.0.28)] on darwin
[GCC“Helloin3range(5):Apple LLVM 4.2or
"help", "copyright", "credits"
+ 2
...
‘Hello World’ more
>>> "help", i
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
print
... x + 100
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
0
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
1
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
3
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
4
... y
300 x
>>> for print i
‘Hello=World’range(5):
i in
200
100
... x = y in i
>>> for printrange(5):
exit()
y + i
200
100
74. Interactive Shell
>>> x + 200
"license"
Typey"help", more information.
(clang-425.0.28)] on darwin
23:41:46)
Python=2.7.5 "copyright", 20 2013,
$ pythony for(default, May"credits" or
300
>>>
"license"
Typex"help", more information.
[GCC14.2.1+Compatible May LLVM 4.2
23:41:46) for"copyright", "credits"
Python+2.7.53(default,Apple20 2013, or
y
2
300
6
>>> 14.2.1
"license" +Compatible
(clang-425.0.28)] information.
[GCCfor i for moreon darwin
23:41:46) in3range(5):Apple LLVM 4.2
+ 2
... "help", i
6
>>> 14.2.1+World”
Typefor print"copyright", "credits"
(clang-425.0.28)] on darwin
[GCC“Helloin3range(5):Apple LLVM 4.2or
+ i Compatible
2
...
‘Hello World’ more
>>> "help", i
6
"license" World” information.
Type“Hellofor"copyright", "credits" or
(clang-425.0.28)] on darwin
print
0
... x + 100
‘Hello=World’
>>> 1"help",3 more
"license" +World” information.
Type“Hellofor"copyright", "credits" or
2
1
0
‘Hello+ 100 3
6
>>> 1 =World’
"license" for more information.
y
x
200
2 +
2
1
6
>>> “Hello+World”
y
x + 100 3
1 = y
200
2
3
2
300 y + y
‘Hello=World’
>>> “Hello World”
6
x
200
4
3
300 for y World”
‘Hello=World’
>>> “Helloin range(5):
x + i
100
4
... y
300 x
>>> for print i
‘Hello=World’range(5):
exit()in
i
200
100
$
... x = y in i
>>> for printrange(5):
exit()
y + i
200
100
81. A Python Code
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
9x9table.py
82. script language
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
no specified entry point
86. If you need a main function
as entry point,
if __name__ == “__main__”:
print “Hello World!”
87. If you need a main function
as entry point,
if __name__ == “__main__”:
print “Hello World!”
88. If you need a main function
as entry point,
if __name__ == “__main__”:
print “Hello World!”
and write all statements after it.
89. variable
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
can be used without declaration
90. variable
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
can be used without declaration
91. scope
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
use whitespace to identify scope
92. scope
def mul(x, y):
ret = x * y
return ret
for i in range(10)[2:]:
for j in range(10)[1:]:
print "{0} x {1} = {2}".format(i, j,
mul(i, j))
use whitespace to identify scope
166. Cross-line String
Contents are
surrounded by
three single
quotes or three
double quotes.
>>> “““Hello
... World!”””
‘HellonWorld!’
>>> x = “““Hello
... World!”””
>>>
167. Cross-line String
Contents are
surrounded by
three single
quotes or three
double quotes.
>>> “““Hello
... World!”””
‘HellonWorld!’
>>> x = “““Hello
... World!”””
>>> print x
168. Cross-line String
Contents are
surrounded by
three single
quotes or three
double quotes.
... World!”””
>>> “““Hello
‘HellonWorld!’
... World!”””
>>> x = “““Hello
‘HellonWorld!’
... x = “““Hello
>>> World!”””
>>> print x
... World!”””
Hello
>>> print x
World!
>>>
369. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
370. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
371. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
372. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
373. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
374. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
...
375. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
...
print i
376. Addition for Loop
skip remaining statement and
continue
continue loop
>>> for i in range(5):
...
if i == 2:
...
continue
...
print i
...
377. Addition for Loop
skip remaining statement and
continue
continue loop
...
>>> for ifin range(5):
i i == 2:
...
if icontinue
== 2:
...
print i
continue
...
print i
0
...
1
3
4
>>>
393. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
394. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
...
395. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
...
print “done”
396. Addition for Loop
else
do something after unbroken
loop
>>> for i in range(3):
...
print i
... else:
...
print “done”
...
397. Addition for Loop
else
do something after unbroken
loop
...
>>> for i in range(3):
print i
... else:
print i
... else:
print “done”
...
print “done”
0
...
1
2
done
>>>