sum = 0
x = 1
n = 1
while True:
sum += 2**n
if n == 20:
sum += 1
break
print sum
x = 1
n = 1
while True:
sum += 2**n
if n == 20:
sum += 1
break
print sum
2015-10-03
score = 55
if score >= 60:
print "passed"
else:
print "failed"
if score >= 60:
print "passed"
else:
print "failed"
2015-10-02
L = ['Adam', 'Lisa', 'Bart']
L.insert(2,'Pual')
print L
L.insert(2,'Pual')
print L
2015-10-02
L = [95.5, 85, 59]
print L[0]
print L[1]
print L[2]
木有第四个 老师出错了吧
print L[0]
print L[1]
print L[2]
木有第四个 老师出错了吧
2015-10-02
# -*- coding: utf-8 -*-
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print u'''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
2015-10-02
print 'Python was started in 1989 by \"Guido\." \nPython is free and easy to learn.'
2015-10-02
print [m*100+n*10+d for m in range(1,10) for n in range(0,10) for d in range(1,10) if m==d]
2015-10-02
def firstCharUpper(s):
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[:1].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-10-02
L = range(1, 101)
def range(a,b):
Li=[]
while a<b:
Li.append(a)
a=a+1
return Li
print L[:10]
print L[2::3]
print L[4:50:5]
def range(a,b):
Li=[]
while a<b:
Li.append(a)
a=a+1
return Li
print L[:10]
print L[2::3]
print L[4:50:5]
2015-10-02
def move(n, a, b, c):
if n==1:
print a,'-->',c
else:
move(n-1,a,c,b)
print a,'-->',c
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
else:
move(n-1,a,c,b)
print a,'-->',c
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
2015-10-02