现在是python 3了。所以这道题最难的地方在与return的地方太长导致代码必须换行。这个时候除了def的语句块前面的地方需要缩进外,换行符号的下一行还要再加一个缩进。
def quadratic_equation(a, b, c):
return (-b + math.sqrt(b*b - 4*a*c)) / (2*a), \
(-b - math.sqrt(b*b - 4*a*c)) / (2*a)
print(quadratic_equation(2, 3, 0))
print(quadratic_equation(1, -6, 5))
def quadratic_equation(a, b, c):
return (-b + math.sqrt(b*b - 4*a*c)) / (2*a), \
(-b - math.sqrt(b*b - 4*a*c)) / (2*a)
print(quadratic_equation(2, 3, 0))
print(quadratic_equation(1, -6, 5))
2018-05-10
d = {
'Adam':95,
'LIsa':85,
'Bart':59,
'dict':75,
}
print d.len()
有多少人这么写的。。。。。。。
改不过来
'Adam':95,
'LIsa':85,
'Bart':59,
'dict':75,
}
print d.len()
有多少人这么写的。。。。。。。
改不过来
2018-05-10
print [x*100+y*10+z for x in range(1,10) for y in range(0,10) for z in range(0,10) if x==z ]
2018-05-10
def square_of_sum(L):
sum = 0
for i in L:
sum+=i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum = 0
for i in L:
sum+=i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2018-05-10
print(45678+0x12fd2)
print("Learn python in imooc")
print(100<99)
print(0xff==255)
print("Learn python in imooc")
print(100<99)
print(0xff==255)
2018-05-10
d = {
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,':',d.get(k)
'Adam': 95,
'Lisa': 85,
'Bart': 59
}
for k in d:
print k,':',d.get(k)
2018-05-10