没有第四名……正确代码是:
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L
2015-12-14
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,":",v
print 'average', ':', sum/len(d)
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,":",v
print 'average', ':', sum/len(d)
2015-12-14
题目中的s和编辑框中的s定义不一样:
左边的s 是set(['Adam', 'Paul'])
右边的s 是set(['Adam', 'Lisa', 'Paul'])
左边的s 是set(['Adam', 'Paul'])
右边的s 是set(['Adam', 'Lisa', 'Paul'])
2015-12-14
sum = 0
x = 1
n = 0
while True:
if x > 20:
break
else:
sum = sum + 2**n
n += 1
x += 1
print sum
x = 1
n = 0
while True:
if x > 20:
break
else:
sum = sum + 2**n
n += 1
x += 1
print sum
2015-12-14
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L[-1]
print L[0]
print L[1]
print L[2]
print L[-1]
2015-12-14
for i in range(1,10,1):
for j in range(0,10):
if i<j:
print 10*i+j
for i in range(1,10,1):
for j in range(0,10):
if i<j:
print str(i)+str(j)
for j in range(0,10):
if i<j:
print 10*i+j
for i in range(1,10,1):
for j in range(0,10):
if i<j:
print str(i)+str(j)
2015-12-13
import math
def quadratic_equation(a, b, c):
if a not = 0:
x1 = (-b + math.sqrt(b*b - 4*a*c))/(2*a)
x2 = (-b - math.sqrt(b*b - 4*a*c))/(2*a)
return x1,x2
else:
x = -c/b
return x
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
哪里错了?
def quadratic_equation(a, b, c):
if a not = 0:
x1 = (-b + math.sqrt(b*b - 4*a*c))/(2*a)
x2 = (-b - math.sqrt(b*b - 4*a*c))/(2*a)
return x1,x2
else:
x = -c/b
return x
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
哪里错了?
2015-12-13
# -*- coding: utf-8 -*-
s='''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print s
s='''静夜思
床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。'''
print s
2015-12-13