L = [75, 92, 59, 68]
sum = 0.0
for n in L:
sum = sum + n
print sum / 4
sum = 0.0
for n in L:
sum = sum + n
print sum / 4
2016-03-12
现在本机上 print '\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.'
然后将结果复制粘贴到页面上,用于动手改转义字符
然后将结果复制粘贴到页面上,用于动手改转义字符
2016-03-12
s = 'python was started in 1989 by "Guido".\npython is free and easy to learn.'
print s
print s
2016-03-12
print u'静夜思\n 床前明月光,\n 疑是地上霜。\n 举头望明月,\n 低头思故乡。'
2016-03-12
def firstCharUpper(s):
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2016-03-11
def average(*args):
sum = 0
x = 0
if len(args) == 0:
return 0.0
else:
for n in args:
sum = sum + n
x = x + 1
return 1.0*sum/x
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0
x = 0
if len(args) == 0:
return 0.0
else:
for n in args:
sum = sum + n
x = x + 1
return 1.0*sum/x
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2016-03-11
score = 85
if score>=90:
print 'excellent'
elif score>=80:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
if score>=90:
print 'excellent'
elif score>=80:
print 'good'
elif score>=60:
print 'passed'
else:
print 'failed'
2016-03-11
score = 55
if score>=60:
print 'passed'
else:
print 'failed'
if score>=60:
print 'passed'
else:
print 'failed'
2016-03-11