最新回答 / 慕函数0346336
# -*- coding: utf-8 -*d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}for key, value in d.items(): n=1 for score in value: print('{}的第{}次成绩是{}'.format(key, n, score)) n = n+1
Bob的第...
2020-10-13
按题目要求,应该是这么写吧
L = [95.5, 85, 59, 66, 72]
L2 = sorted(L,reverse=True)
print(L2[0:3])
L = [95.5, 85, 59, 66, 72]
L2 = sorted(L,reverse=True)
print(L2[0:3])
2020-10-10
最赞回答 / 慕标7081267
<...code...>name = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']score = [89, 72, 88, 79, 99]scores = [89, 72, 88, 79, 99]score.sort(reverse = True)rank = []for i in range(len(score)): for j in range(len(score)): if score[i] == scores[...
2020-10-09
最新回答 / mixuelantang
短路计算。真 and 假 总是输出假,所以True and 0输出0,你也说了False和0等价,所以输出0和输出False等价。假 or 真 总是输出真,是指输出真的那个语句,如果先赋值a = False, 0 or a 则输出False即a 的值
2020-10-08
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
names = ["Alice", "Bob", "Candy", "Mimi", "David"]
for key, name in zip(d.keys(), names):
if name in d.keys():
print(d.get(key))
else:
print(None)
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
names = ["Alice", "Bob", "Candy", "Mimi", "David"]
for key, name in zip(d.keys(), names):
if name in d.keys():
print(d.get(key))
else:
print(None)
2020-10-03
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
最赞回答 / qq_慕神4044404
再少点是这样:L = ['Alice', 66, 'Bob', True, 'Flase', 100]for i in range(len(L)): if i % 2 == 0: print(L[i])
2020-09-29