答案应该是:
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
# Enter a code
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for i in L:
if i in S:
S.remove(i)
else:
S.add(i)
print S
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for i in L:
if i in S:
S.remove(i)
else:
S.add(i)
print S
2021-03-31
# Enter a code
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
a = 'Alice'
for i in name_set:
if a.lower() in i.lower():
print "True"
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
a = 'Alice'
for i in name_set:
if a.lower() in i.lower():
print "True"
2021-03-31