最赞回答 / 万象天心
如果按你的思路的话 我想不出如果实现目的的话 你可以试试这样 看看对不对
s1 = 'ABC' s2 = '123' s3 = 'xyz' s = s1 + s2 + s3 count = 0 for a in s: for b in s: for c in s: ...
2021-04-04
最赞回答 / 万象天心
isdisjoint()方法 如果有重合,返回False,否则返回True。 s1 = set([1, 2, 3, 4, 5]) s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9]) s1.isdisjoint(s2) 为False 故执行else
2021-04-04
答案应该是:
s1 = 'ABC'
s2 = '123'
s3='xyz'
for z in s3:
for x in s1:
for y in s2:
print(x + y+ z);
print(x + z+ y);
print(y + x+ z);
print(y + z+ x);
print(z + x+ y);
print(z + y+ x);
s1 = 'ABC'
s2 = '123'
s3='xyz'
for z in s3:
for x in s1:
for y in s2:
print(x + y+ z);
print(x + z+ y);
print(y + x+ z);
print(y + z+ x);
print(z + x+ y);
print(z + y+ x);
2021-04-04
# Enter a code
L = [75, 92, 59, 68, 99]
sum = 0.0
for s in L:
sum = sum + s
ave = sum / len(L)
print(ave)
L = [75, 92, 59, 68, 99]
sum = 0.0
for s in L:
sum = sum + s
ave = sum / len(L)
print(ave)
2021-04-03
# Enter a code
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names.append('Zero')
names.insert(-2,'Gen')
names.insert(-2,'Phoebe')
print(names)
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names.append('Zero')
names.insert(-2,'Gen')
names.insert(-2,'Phoebe')
print(names)
2021-04-02
L = [95.5, 85, 59, 66, 72]
L.sort(reverse = False)
print('first: ',L[-1])
print('second: ',L[-2])
print('third: ',L[-3])
L.sort(reverse = False)
print('first: ',L[-1])
print('second: ',L[-2])
print('third: ',L[-3])
2021-04-02
# Enter a code
L = [95.5, 85, 59, 66, 72]
L.sort(reverse = True)
print('first: ',L[0])
print('second: ',L[1])
print('third: ',L[2])
L = [95.5, 85, 59, 66, 72]
L.sort(reverse = True)
print('first: ',L[0])
print('second: ',L[1])
print('third: ',L[2])
2021-04-02
# Enter a code
courses = ['Chinese', 'Match', 'English']
scores = [92, 75, 99]
oder = [0, 1, 2]
print ('Alice\' score: ')
for i in oder:
print (courses[i],': ',scores[i])
courses = ['Chinese', 'Match', 'English']
scores = [92, 75, 99]
oder = [0, 1, 2]
print ('Alice\' score: ')
for i in oder:
print (courses[i],': ',scores[i])
2021-04-02
最赞回答 / 阿呦喂
python中的缩进起到了区别不同功能模块的作用,就像c中的{}和;一样,for循环中的缩进就说明了这条语句是受for控制的,相关运算需要满足for循环的条件,如果没有缩进,就不受for控制,这里sum=...
2021-04-01
已采纳回答 / 小白兔cai
print(round(average(1,2,2,3,4),2))你可以把打印结果改成这样,就会出现2.4,有可能你使用的编辑器版本问题,默认打印结果为整型,不保留小数点。
2021-04-01
# Enter a code
def list_a(a):
result = 0
for i in a:
result += i*i
return result
L = [10,20]
print list_a(L)
def list_a(a):
result = 0
for i in a:
result += i*i
return result
L = [10,20]
print list_a(L)
2021-03-31