最新回答 / AI小慕
问题解答
核心问题:如何使用Python字符串切片来从给定的字符串中提取特定子串。
根据你的描述,你需要从字符串 'AABCDEFGHHIJ' 中取出子串 'ABCDEFGH'。根据提供的背景信息,你可以通过指定正确...
2024-11-06
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
extend_set = set([])
for i in name_set:
extend_set.add(i.lower())
name = 'Bob'
new_name = name.lower()
if new_name in extend_set:
print('{} is in the class'.format(name))
else:
print("{} isn't in the class".format(name))
name_set = set(names)
extend_set = set([])
for i in name_set:
extend_set.add(i.lower())
name = 'Bob'
new_name = name.lower()
if new_name in extend_set:
print('{} is in the class'.format(name))
else:
print("{} isn't in the class".format(name))
2024-11-04
最新回答 / AI小慕
核心问题
你的代码逻辑中,num = num + 1 的位置不当。在 continue 语句之后立即增加 num 的值会导致当 num 是奇数时(即 num % 2 & 是奇 0),它被跳过而没有计入求和过程。此外,你的代码格式...
2024-10-28
d = {
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
d.setdefault("Gaven",86)
print(d)
'Alice': 45,
'Bob': 60,
'Candy': 75,
'David': 86,
'Ellena': 49
}
d.setdefault("Gaven",86)
print(d)
2024-10-12
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if s1.isdisjoint(s2) is True:
print('无重复集合')
else:
for a in s1:
if a in s2:
print(a)
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if s1.isdisjoint(s2) is True:
print('无重复集合')
else:
for a in s1:
if a in s2:
print(a)
2024-09-19
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for a in L:
if a in S:
S.remove(a)
else:
S.add(a)
print(S)
S = set([1, 3, 5, 7, 9, 11])
for a in L:
if a in S:
S.remove(a)
else:
S.add(a)
print(S)
2024-09-19
已采纳回答 / yi9283746
第一个函数,当a=100时,由于a+1大于100,使得其直接返回而不是100+my_sumA(101),你应该把+1去掉或者把100改为101
2024-09-07
最新回答 / qq_慕侠3039784
L = [[1,2,3], [5, 3, 2], [7,3,2]]N=3s=0if N>=1: for cube in L: length = cube[0] width = cube[1] height = cube[2] result = length * width * 2 + width * height * 2 + length * height * 2 print(result) s=s+resul...
2024-09-05
直接这样一句话就可以了吧。
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
print(len(d))
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
print(len(d))
2024-08-28
# Enter a code
K = ['Chinese','Math','nglish']
F = [92,75,99]
for k,f in zip(K, F):
print(k+':'+str(f))
K = ['Chinese','Math','nglish']
F = [92,75,99]
for k,f in zip(K, F):
print(k+':'+str(f))
2024-08-13
最新回答 / qq_慕函数1434747
你这个代码会一直输出 所有偶数 1000以内的限制没起到作用,你把 if num<=1000: continue改成
num > :就对了
2024-08-13
num=0
sum=0
while True:
if num<=1000:
num=num+2
continue
sum=sum+num
print(sum)
sum=0
while True:
if num<=1000:
num=num+2
continue
sum=sum+num
print(sum)
2024-08-13