num = 0
sum = 0
while True:
if num > 1000:
break
if num % 2 == 0 :
sum = num + sum
num = num + 1
print(sum) =》 250500
sum = 0
while True:
if num > 1000:
break
if num % 2 == 0 :
sum = num + sum
num = num + 1
print(sum) =》 250500
2021-06-10
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
for key in d:
value = d[key]
for ch in value:
print (key,ch)
for key in d:
value = d[key]
for ch in value:
print (key,ch)
2021-06-04
已采纳回答 / qq_蓝烟_vyFLU4
s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'num=0while num<20: print(s[num]) num = num + 1
2021-06-03
最赞回答 / qq_慕容3463716
names = kwargs['names'] # 入参取值,意思是调用info方法时会传入参数名为names的参数 gender_list = kwargs['gender'] # 同上 age_list = kwargs['age'] # 同上 index = 0 # 定义一个索引用于获取 names、gend...
2021-06-03
print("这是一句中英文混合的%s字符串:%s"%("python","Hello\tWorld"))
2021-06-02
template1="Life is short"
template2="you need python"
print("{0},{1}".format(template1,template2))
template="{L},{y}"
L="life is short"
y="you need python"
print(template.format(L=L,y=y))
template2="you need python"
print("{0},{1}".format(template1,template2))
template="{L},{y}"
L="life is short"
y="you need python"
print(template.format(L=L,y=y))
2021-06-02
print(r'''"To be, or not to be":that is the question
Whether it's nobler in the mind to suffer.''')
Whether it's nobler in the mind to suffer.''')
2021-06-02
已采纳回答 / 小白白白净
遍历过程中对集合 s 执行 remove 和 add 操作会导致集合 s 的 size 发生改变。即引发RuntimeError: Set changed size during iteration异常
2021-05-31
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
S=[89, 72, 88, 79, 99]
Ss=[89, 72, 88, 79, 99]
def getnames(name):
return Ss.index(name)
S.sort(reverse=True);
for sa in S:
print(sa)
print(L[getnames(sa)])
print(r'''
''')
S=[89, 72, 88, 79, 99]
Ss=[89, 72, 88, 79, 99]
def getnames(name):
return Ss.index(name)
S.sort(reverse=True);
for sa in S:
print(sa)
print(L[getnames(sa)])
print(r'''
''')
2021-05-31