names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
score = [89, 72, 88, 79, 99]
for j in range(len(score)):
for i in range(len(names) - 1):
if score[i] > score[i + 1]:
temp = names[i]
names[i] = names[i + 1]
names[i + 1] = temp
print(names)
score = [89, 72, 88, 79, 99]
for j in range(len(score)):
for i in range(len(names) - 1):
if score[i] > score[i + 1]:
temp = names[i]
names[i] = names[i + 1]
names[i + 1] = temp
print(names)
2020-10-03
length =3.14
width=1.57
result=round(length*width)
print(result)
不用加变量类型和分号,简单的有点不习惯
width=1.57
result=round(length*width)
print(result)
不用加变量类型和分号,简单的有点不习惯
2020-09-30
s1 = 'ABC'
s2 = '123'
s3 = 'xyz'
for x in s1:
for y in s2:
for z in s3:
print (x + y + z)
print (x + z + y)
print (y + x + z)
print (y + z + x)
print (z + x + y)
print (z + y + x)
s2 = '123'
s3 = 'xyz'
for x in s1:
for y in s2:
for z in s3:
print (x + y + z)
print (x + z + y)
print (y + x + z)
print (y + z + x)
print (z + x + y)
print (z + y + x)
2020-09-30
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if not s1.isdisjoint(s2):
for i in s1:
if i in s2:
print(i)
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if not s1.isdisjoint(s2):
for i in s1:
if i in s2:
print(i)
2020-09-23