d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
if 'Alice' in d:
d.pop('Alice')
print(d)
else:
print("don't have Alice")
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
if 'Alice' in d:
d.pop('Alice')
print(d)
else:
print("don't have Alice")
2023-11-28
最新回答 / weixin_慕仰3352044
d = { 'Alice': 45, 'Bob': 60, 'Candy': 75, 'David': 86, 'Ellena': 49}names = ['Alice', 'Bob', 'Candy', 'Mimi', 'David']for item in names: print('{} score:{}'.format(item,d.get(item)))
2023-11-28
最新回答 / 翎栋
7-1答案,你这不是已经写了么新来的Gaven同学成绩是86,请编写一个dict,把Gaven同学的成绩也加进去。<...code...>
d = { 'Alice': 45, 'Bob': 60, 'Candy': 75, 'David': 86, 'Ellena': 49} d['Gaven'] = 86 print(d)
2023-11-28
i = 0
sum = 0
while True:
if i > 1000:
break
else:
if i % 2 == 0:
sum += i
i += 1
print(sum)
sum = 0
while True:
if i > 1000:
break
else:
if i % 2 == 0:
sum += i
i += 1
print(sum)
2023-11-23
最新回答 / weixin_慕UI4308435
num = 0 # 初始化num用于存放偶数和for i in range(0, 1001, 1): # 利用range从0开始循环到1001(不包含1001),每次递增1,循环到1001等同于i<=1000 if i % 2 != 0:# 如果i除以2的余数不为0则说明i不能被2整除,此时i的值为奇数 num += i # 将i的值存到num中 continue# 不能被整除则跳过当前循环print(num) # 输出num的值,也就是1000以内所有偶...
2023-11-22
num = 0 # 初始化num用于存放偶数和
for i in range(0, 1001, 1): # 利用range从0开始循环到1001,每次递增1,循环到1001等同于i<=1000
if i % 2 != 0: # 如果i除以2的余数不为0则说明i不能被2整除,此时i的值为奇数
continue # 不能被整除则跳过当前循环
num += i # 将i的值存到num中
print(num) # 输出num的值,也就是1000以内所有偶数的值
for i in range(0, 1001, 1): # 利用range从0开始循环到1001,每次递增1,循环到1001等同于i<=1000
if i % 2 != 0: # 如果i除以2的余数不为0则说明i不能被2整除,此时i的值为奇数
continue # 不能被整除则跳过当前循环
num += i # 将i的值存到num中
print(num) # 输出num的值,也就是1000以内所有偶数的值
2023-11-22
template = 'Life is {0},you need {1}'
result = template.format('short','python')
print(result)
template = 'Life is {s} , you need {p}'
short ='short'
python = 'python'
result = template.format(s =short , p = python)
print(result)
result = template.format('short','python')
print(result)
template = 'Life is {s} , you need {p}'
short ='short'
python = 'python'
result = template.format(s =short , p = python)
print(result)
2023-11-16
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.''')
2023-11-04
在计算a and b时,如果 a 是 False,则根据与运算法则,整个结果必定为 False,因此返回 a;如果 a 是 True,则整个计算结果必定取决与 b,因此返回 b。
在计算a or b时,如果 a 是 True,则根据或运算法则,整个计算结果必定为 True,因此返回 a;如果 a 是 False,则整个计算结果必定取决于 b,因此返回 b。
在计算a or b时,如果 a 是 True,则根据或运算法则,整个计算结果必定为 True,因此返回 a;如果 a 是 False,则整个计算结果必定取决于 b,因此返回 b。
2023-11-04
def greet(x='World'):
if x == 'World':
print('Hello World')
else:
print('Hello1,{}'.format(x))
greet('Hello')
greet()
if x == 'World':
print('Hello World')
else:
print('Hello1,{}'.format(x))
greet('Hello')
greet()
2023-10-29