# mikegao/mikegao.github.com

Site updated at 2013-01-29 06:01:38 UTC

1 parent 3082b09 commit 3e83942cea349bada408ed3b9225a293fe47c262 committed Jan 29, 2013
 @@ -158,6 +158,10 @@

23 archives/index.html
 @@ -9,8 +9,9 @@ - + @@ -78,6 +79,20 @@

Blog Archive

+ + + +
202 atom.xml
 @@ -4,7 +4,7 @@ <![CDATA[Mike Tech]]> - 2013-01-29T10:25:19+08:00 + 2013-01-29T14:00:47+08:00 http://mikegao.github.com/ @@ -14,6 +14,206 @@ + <![CDATA[Beginner_Of_Python]]> + + 2013-01-29T10:42:00+08:00 + http://mikegao.github.com/blog/beginner-of-python + 变量交换 + +
x = 6
+y = 5
+
+x, y = y, x
+print x
+>>> 5
+print y
+>>> 6
+
+ +

if 语句再行内

+ +
print "Hello" if True else "World"
+>>> Hello
+
+ +

+ +

+ +
nfc = ["Packers", "49ers"]
+afc = ["Ravens", "Patriots"]
+print nfc + afc
+>>> ['Packers', '49ers', 'Ravens', 'Patriots']
+
+print str(1) + " world"
+>>> 1 world
+
+pring 1, "world"
+>>> 1 world
+
+print nfc, 1
+>>> ['Packers', '49ers'] 1
+
+ +

+ +
# 除后向下取整
+print 5.0//2
+>>> 2
+# 2的5次方
+print 2**5
+>>> 32
+
+ +

+ +
print .3/.1
+>>> 2.9999999999999996
+print .3//.1
+>>> 2.0
+
+ +

+ +
x = 2
+if 3 > x > 1:
+  print x
+>>> 2
+if 1 < x > 0:
+  print x
+>>> 2
+
+ +

+ +
nfc = ['Packers', '49ers']
+afc = ['Ravens', 'Patriots']
+for teama, teamb in zip(nfc, afc)
+  print teama + " vs. " + teamb
+>>> Packers vs. Ravens
+>>> 49ers vs. Patriots
+
+ +

+ +
teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for index, team in enumerate(teams):
+  print index, team
+>>> 0 Packers
+>>> 1 49ers
+>>> 2 Ravens
+>>> 3 Patriots
+
+ +

+ +

+ +
numbers = [1,2,3,4,5]
+even = [number for number in numbers if number%2 == 0]
+
+ +

+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print {key: value for value, key in enumerate(teams)}
+>>> {'49ers': 1, 'Ravens': 2, 'Patriots': 3, 'Packers': 0}
+
+ +

+ +
items = [0]*3
+print items
+>>> [0, 0, 0]
+
+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print ", ".join(teams)
+>>> 'Packers, 49ers, Ravens, Patriots'
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+try:
+except KeyError:
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+
+ +

+ +
x= [1,2,3,4,5]
+# 前3个
+print x[:3]
+>>> [1, 2, 3]
+# 中间4个
+print x[1:5]
+>>> [2, 3, 4, 5]
+# 最后3个
+print x[3:]
+>>> [4, 5, 6]
+# 奇数项
+print x[::2]
+>> [1, 3, 5]
+# 偶数项
+print x[1::2]
+>> [2, 4, 6]
+
+ +

60个字符解决FizzBuzz

+ +

+ +
for x in range(101):print'fizz'[x%3*4::]+'buzz'[x%5*4::]or x
+
+ +

+ +
from collections import Counter
+print Counter("hello")
+>>> Counter({'1': 2, 'h': 1, 'e': 1, 'o': 1})
+
+ +

+ +

+ +
from itertools import combinations
+teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for game in combinations(teams, 2):
+  print game
+>>> ('Packers', '49ers')
+>>> ('Packers', 'Ravens')
+>>> ('Packers', 'Patriots')
+>>> ('49ers', 'Ravens')
+>>> ('49ers', 'Patriots')
+>>> ('Ravens', 'Patriots')
+
+ +

False == True

+ +
False = True
+if False:
+  print "Hello"
+else:
+  print "World"
+>>> Hello
+
+]]>
+
+ + <![CDATA[Hello World]]> 2013-01-29T10:23:00+08:00
23 blog/archives/index.html
 @@ -9,8 +9,9 @@ - + @@ -78,6 +79,20 @@

Blog Archive

+ + + +
413 blog/beginner-of-python/index.html
 @@ -0,0 +1,413 @@ + + + + + + + + Beginner_Of_Python - Mike Tech + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Mike Tech

+ +
+ +
+ +
+
+
+
+ +
+ +

Beginner_Of_Python

+ + +

+ + + + + + + + + + + + + + +

+ +
+ + +

+ +
x = 6
+y = 5
+
+x, y = y, x
+print x
+>>> 5
+print y
+>>> 6
+
+ +

if 语句再行内

+ +
print "Hello" if True else "World"
+>>> Hello
+
+ +

+ +

+ +
nfc = ["Packers", "49ers"]
+afc = ["Ravens", "Patriots"]
+print nfc + afc
+>>> ['Packers', '49ers', 'Ravens', 'Patriots']
+
+print str(1) + " world"
+>>> 1 world
+
+pring 1, "world"
+>>> 1 world
+
+print nfc, 1
+>>> ['Packers', '49ers'] 1
+
+ +

+ +
# 除后向下取整
+print 5.0//2
+>>> 2
+# 2的5次方
+print 2**5
+>>> 32
+
+ +

+ +
print .3/.1
+>>> 2.9999999999999996
+print .3//.1
+>>> 2.0
+
+ +

+ +
x = 2
+if 3 > x > 1:
+  print x
+>>> 2
+if 1 < x > 0:
+  print x
+>>> 2
+
+ +

+ +
nfc = ['Packers', '49ers']
+afc = ['Ravens', 'Patriots']
+for teama, teamb in zip(nfc, afc)
+  print teama + " vs. " + teamb
+>>> Packers vs. Ravens
+>>> 49ers vs. Patriots
+
+ +

+ +
teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for index, team in enumerate(teams):
+  print index, team
+>>> 0 Packers
+>>> 1 49ers
+>>> 2 Ravens
+>>> 3 Patriots
+
+ +

+ +

+ +
numbers = [1,2,3,4,5]
+even = [number for number in numbers if number%2 == 0]
+
+ +

+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print {key: value for value, key in enumerate(teams)}
+>>> {'49ers': 1, 'Ravens': 2, 'Patriots': 3, 'Packers': 0}
+
+ +

+ +
items = [0]*3
+print items
+>>> [0, 0, 0]
+
+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print ", ".join(teams)
+>>> 'Packers, 49ers, Ravens, Patriots'
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+try:
+except KeyError:
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+
+ +

+ +
x= [1,2,3,4,5]
+# 前3个
+print x[:3]
+>>> [1, 2, 3]
+# 中间4个
+print x[1:5]
+>>> [2, 3, 4, 5]
+# 最后3个
+print x[3:]
+>>> [4, 5, 6]
+# 奇数项
+print x[::2]
+>> [1, 3, 5]
+# 偶数项
+print x[1::2]
+>> [2, 4, 6]
+
+ +

60个字符解决FizzBuzz

+ +

+ +
for x in range(101):print'fizz'[x%3*4::]+'buzz'[x%5*4::]or x
+
+ +

+ +
from collections import Counter
+print Counter("hello")
+>>> Counter({'1': 2, 'h': 1, 'e': 1, 'o': 1})
+
+ +

+ +

+ +
from itertools import combinations
+teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for game in combinations(teams, 2):
+  print game
+>>> ('Packers', '49ers')
+>>> ('Packers', 'Ravens')
+>>> ('Packers', 'Patriots')
+>>> ('49ers', 'Ravens')
+>>> ('49ers', 'Patriots')
+>>> ('Ravens', 'Patriots')
+
+ +

False == True

+ +
False = True
+if False:
+  print "Hello"
+else:
+  print "World"
+>>> Hello
+
+
+ + +
+

+ + + + + + + + + + + + + + + + + + + + + + + python + + + + +

+ + + + +

+ + « Hello World + + +

+
+
+ +
+ + + + +
+
+

+ +
+ + + + + + + + + + + + + + + +
216 blog/categories/python/atom.xml
 @@ -0,0 +1,216 @@ + + + + <![CDATA[Category: python | Mike Tech]]> + + + 2013-01-29T14:00:47+08:00 + http://mikegao.github.com/ + + + + + Octopress + + + + <![CDATA[Beginner_Of_Python]]> + + 2013-01-29T10:42:00+08:00 + http://mikegao.github.com/blog/beginner-of-python + 变量交换 + +
x = 6
+y = 5
+
+x, y = y, x
+print x
+>>> 5
+print y
+>>> 6
+
+ +

if 语句再行内

+ +
print "Hello" if True else "World"
+>>> Hello
+
+ +

+ +

+ +
nfc = ["Packers", "49ers"]
+afc = ["Ravens", "Patriots"]
+print nfc + afc
+>>> ['Packers', '49ers', 'Ravens', 'Patriots']
+
+print str(1) + " world"
+>>> 1 world
+
+pring 1, "world"
+>>> 1 world
+
+print nfc, 1
+>>> ['Packers', '49ers'] 1
+
+ +

+ +
# 除后向下取整
+print 5.0//2
+>>> 2
+# 2的5次方
+print 2**5
+>>> 32
+
+ +

+ +
print .3/.1
+>>> 2.9999999999999996
+print .3//.1
+>>> 2.0
+
+ +

+ +
x = 2
+if 3 > x > 1:
+  print x
+>>> 2
+if 1 < x > 0:
+  print x
+>>> 2
+
+ +

+ +
nfc = ['Packers', '49ers']
+afc = ['Ravens', 'Patriots']
+for teama, teamb in zip(nfc, afc)
+  print teama + " vs. " + teamb
+>>> Packers vs. Ravens
+>>> 49ers vs. Patriots
+
+ +

+ +
teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for index, team in enumerate(teams):
+  print index, team
+>>> 0 Packers
+>>> 1 49ers
+>>> 2 Ravens
+>>> 3 Patriots
+
+ +

+ +

+ +
numbers = [1,2,3,4,5]
+even = [number for number in numbers if number%2 == 0]
+
+ +

+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print {key: value for value, key in enumerate(teams)}
+>>> {'49ers': 1, 'Ravens': 2, 'Patriots': 3, 'Packers': 0}
+
+ +

+ +
items = [0]*3
+print items
+>>> [0, 0, 0]
+
+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print ", ".join(teams)
+>>> 'Packers, 49ers, Ravens, Patriots'
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+try:
+except KeyError:
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+
+ +

+ +
x= [1,2,3,4,5]
+# 前3个
+print x[:3]
+>>> [1, 2, 3]
+# 中间4个
+print x[1:5]
+>>> [2, 3, 4, 5]
+# 最后3个
+print x[3:]
+>>> [4, 5, 6]
+# 奇数项
+print x[::2]
+>> [1, 3, 5]
+# 偶数项
+print x[1::2]
+>> [2, 4, 6]
+
+ +

60个字符解决FizzBuzz

+ +

+ +
for x in range(101):print'fizz'[x%3*4::]+'buzz'[x%5*4::]or x
+
+ +

+ +
from collections import Counter
+print Counter("hello")
+>>> Counter({'1': 2, 'h': 1, 'e': 1, 'o': 1})
+
+ +

+ +

+ +
from itertools import combinations
+teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for game in combinations(teams, 2):
+  print game
+>>> ('Packers', '49ers')
+>>> ('Packers', 'Ravens')
+>>> ('Packers', 'Patriots')
+>>> ('49ers', 'Ravens')
+>>> ('49ers', 'Patriots')
+>>> ('Ravens', 'Patriots')
+
+ +

False == True

+ +
False = True
+if False:
+  print "Hello"
+else:
+  print "World"
+>>> Hello
+
+]]>
+
+ +
168 blog/categories/python/index.html
 @@ -0,0 +1,168 @@ + + + + + + + + Category: python - Mike Tech + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Mike Tech

+ +
+ +
+ +
+
+
+
+ +
+

Category: Python

+ +
+ +
+ + + + +

2013

+ + + +
+ + +
+ +
+ + + + +
+
+

+ +
+ + + + + + + + + + + + + + + +
6 blog/hello-world/index.html
 @@ -131,6 +131,8 @@

Hello World

+ Beginner_Of_Python » +

@@ -163,6 +165,10 @@

Hello World

239 index.html
 @@ -9,8 +9,12 @@ - + @@ -69,6 +73,233 @@
+

Beginner_Of_Python

+ + +

+ + + + + + + + + + + + + + +

+ +
+ + +

+ +
x = 6
+y = 5
+
+x, y = y, x
+print x
+>>> 5
+print y
+>>> 6
+
+ +

if 语句再行内

+ +
print "Hello" if True else "World"
+>>> Hello
+
+ +

+ +

+ +
nfc = ["Packers", "49ers"]
+afc = ["Ravens", "Patriots"]
+print nfc + afc
+>>> ['Packers', '49ers', 'Ravens', 'Patriots']
+
+print str(1) + " world"
+>>> 1 world
+
+pring 1, "world"
+>>> 1 world
+
+print nfc, 1
+>>> ['Packers', '49ers'] 1
+
+ +

+ +
# 除后向下取整
+print 5.0//2
+>>> 2
+# 2的5次方
+print 2**5
+>>> 32
+
+ +

+ +
print .3/.1
+>>> 2.9999999999999996
+print .3//.1
+>>> 2.0
+
+ +

+ +
x = 2
+if 3 > x > 1:
+  print x
+>>> 2
+if 1 < x > 0:
+  print x
+>>> 2
+
+ +

+ +
nfc = ['Packers', '49ers']
+afc = ['Ravens', 'Patriots']
+for teama, teamb in zip(nfc, afc)
+  print teama + " vs. " + teamb
+>>> Packers vs. Ravens
+>>> 49ers vs. Patriots
+
+ +

+ +
teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for index, team in enumerate(teams):
+  print index, team
+>>> 0 Packers
+>>> 1 49ers
+>>> 2 Ravens
+>>> 3 Patriots
+
+ +

+ +

+ +
numbers = [1,2,3,4,5]
+even = [number for number in numbers if number%2 == 0]
+
+ +

+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print {key: value for value, key in enumerate(teams)}
+>>> {'49ers': 1, 'Ravens': 2, 'Patriots': 3, 'Packers': 0}
+
+ +

+ +
items = [0]*3
+print items
+>>> [0, 0, 0]
+
+ +

+ +
teams = ['Packers', '49ers', 'Ravens', 'Patriots']
+print ", ".join(teams)
+>>> 'Packers, 49ers, Ravens, Patriots'
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+try:
+except KeyError:
+
+ +

+ +
data = {'user': 1, 'name': 'Max', 'three': 4}
+
+ +

+ +
x= [1,2,3,4,5]
+# 前3个
+print x[:3]
+>>> [1, 2, 3]
+# 中间4个
+print x[1:5]
+>>> [2, 3, 4, 5]
+# 最后3个
+print x[3:]
+>>> [4, 5, 6]
+# 奇数项
+print x[::2]
+>> [1, 3, 5]
+# 偶数项
+print x[1::2]
+>> [2, 4, 6]
+
+ +

60个字符解决FizzBuzz

+ +

+ +
for x in range(101):print'fizz'[x%3*4::]+'buzz'[x%5*4::]or x
+
+ +

+ +
from collections import Counter
+print Counter("hello")
+>>> Counter({'1': 2, 'h': 1, 'e': 1, 'o': 1})
+
+ +

+ +

+ +
from itertools import combinations
+teams = ["Packers", "49ers", "Ravens", "Patriots"]
+for game in combinations(teams, 2):
+  print game
+>>> ('Packers', '49ers')
+>>> ('Packers', 'Ravens')
+>>> ('Packers', 'Patriots')
+>>> ('49ers', 'Ravens')
+>>> ('49ers', 'Patriots')
+>>> ('Ravens', 'Patriots')
+
+ +

False == True

+ +
False = True
+if False:
+  print "Hello"
+else:
+  print "World"
+>>> Hello
+
+
+ + + + + + + +
10 sitemap.xml
 @@ -5,20 +5,24 @@ 2013-01-29T10:25:04+08:00 + http://mikegao.github.com/blog/beginner-of-python/ + 2013-01-29T14:00:46+08:00 + + http://mikegao.github.com/about/ 2013-01-29T10:19:23+08:00 http://mikegao.github.com/archives/ - 2013-01-29T10:25:04+08:00 + 2013-01-29T14:00:46+08:00 http://mikegao.github.com/blog/archives/ - 2013-01-29T10:25:04+08:00 + 2013-01-29T14:00:46+08:00 http://mikegao.github.com/ - 2013-01-29T10:25:04+08:00 + 2013-01-29T14:00:46+08:00 http://mikegao.github.com/robots.txt