s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
a=x[0]
b=x[1]
print a,':',b
for x in s:
a=x[0]
b=x[1]
print a,':',b
2020-03-08
已采纳回答 / qq_慕仙0250366
list[]集合是可以改变的啊 tuple()集合是不可以改动的 t()里面有list的把list改成tuple()的形式它就不能改动了
2020-03-08
s = "Python was started in 1989 by\"Guido\".\n Python is free and easy to learn."
print s
print s
2020-03-07
print"hello,python"
print"hello,"+"python"
print"hello,"+"python"
2020-03-07
import math
def quadratic_equation(a, b, c):
if b**2-4*a*c>0:
x1=(-b+math.sqrt(b**2-4*a*c))/(2*a)
x2=(-b-math.sqrt(b**2-4*a*c))/(2*a)
return x1,x2
else:
return none
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
if b**2-4*a*c>0:
x1=(-b+math.sqrt(b**2-4*a*c))/(2*a)
x2=(-b-math.sqrt(b**2-4*a*c))/(2*a)
return x1,x2
else:
return none
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2020-03-06
def square_of_sum(L):
s=set(L)
x=0
y=len(s)
while x+1<=y:
for a in L:
L[x]=a*a
x=x+1
return sum(L)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
s=set(L)
x=0
y=len(s)
while x+1<=y:
for a in L:
L[x]=a*a
x=x+1
return sum(L)
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2020-03-06
s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
n=0
while n<4:
if L[n] in s:
s.remove(L[n])
else:
s.add(L[n])
n=n+1
print s
L = ['Adam', 'Lisa', 'Bart', 'Paul']
n=0
while n<4:
if L[n] in s:
s.remove(L[n])
else:
s.add(L[n])
n=n+1
print s
2020-03-06