L = []
x = 1
while x <= 100:
L.append(x**2)
x += 1
print sum(L)
x = 1
while x <= 100:
L.append(x**2)
x += 1
print sum(L)
2019-02-21
def area_of_circle(x):
x = 2
s = 3.14*x**2
print(s)
if __name__ == '__area_of_circle__':
area_of_circle()
x = 2
s = 3.14*x**2
print(s)
if __name__ == '__area_of_circle__':
area_of_circle()
2019-02-21
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
for x in L:
if x in s:
s.remove(x)
else:
s.add(x)
print s
2019-02-21
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print('{}:{}'.format(x[0],x[1]))
for x in s:
print('{}:{}'.format(x[0],x[1]))
2019-02-21
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
list_a = ['adam', 'bart']
for x in list_a:
y = x.title()
print y in s
答案一般般,和闹着玩一样
list_a = ['adam', 'bart']
for x in list_a:
y = x.title()
print y in s
答案一般般,和闹着玩一样
2019-02-21
import math
def quadratic_equation(a, b, c):
q=b*b-4*a*c
if q>=0:
x1=(-b+math.sqrt(q))/(2*a)
x2=(-b-math.sqrt(q))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
q=b*b-4*a*c
if q>=0:
x1=(-b+math.sqrt(q))/(2*a)
x2=(-b-math.sqrt(q))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2019-02-20