L = [95.5, 85, 59, 66, 72]
N = []
for item in L:
if(item > 60):
N.append(item)
N.sort(reverse=True)
print(N)
N = []
for item in L:
if(item > 60):
N.append(item)
N.sort(reverse=True)
print(N)
2023-04-24
template = 'life is short,{}'
print(template.format('you need Python'))
template = "life is {0},you need {1}"
print(template.format('short','Python'))
print(template.format('you need Python'))
template = "life is {0},you need {1}"
print(template.format('short','Python'))
2023-04-24
最新回答 / 月夜妖华
def func(L): s = 0 c = 1 if isinstance(L, list): s = sum(L) return s elif isinstance(L, tuple): for F in L: c = c * F return c else: print("Error")print(func([1, 2, 3]))print(func((1, 2,...
2023-04-22
最赞回答 / 月夜妖华
def square_of_sum(x): result = 0 y = [] for M in x: y.append(M * M) result = sum(y) return resultprint(square_of_sum([1, 2, 3, 4, 5]))print(square_of_sum([-5, 0, 5, 15, 25]))你把创建空列表放在循环外就正确了,如果循环一次就创建一个新的列表,那后面的列表会覆盖前面的列表,第一个列表最后...
2023-04-22
最赞回答 / 程序猿_郭文超
你可以这么理解,假如说你开了一家酒吧,进酒吧的人可以吃喝玩乐,但是你的酒吧为了盈利需要门票,所以每个进去的人都需要买门票,然后门口有一个人验票后才能入场。从这个例子中 你可以理解为 酒吧 就是一个方法,进去的人 吃喝玩乐指的是方法内你对于进去的人的行为的操作,而门票你可以理解为就是方法的参数也就是你指定的规则。所以定义的方法中需要有方法名,即你酒吧的名字(得让调用者能找到),然后还需要有对于参数操作即行为的定义,然后参数就是限定的规则。目前python中都是类似于弱类型,像JAVA这种在定义方法的时候回定...
2023-04-21
# Enter a code
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
print(s2.intersection(s1))
{1, 2, 3, 4, 5}
print(s2.difference(s1))
{8, 9, 6, 7}
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
print(s2.intersection(s1))
{1, 2, 3, 4, 5}
print(s2.difference(s1))
{8, 9, 6, 7}
2023-04-11
score = {}
if score > 18:
print('adult')
else:
print('teenager')
结果是 adult,求解惑
if score > 18:
print('adult')
else:
print('teenager')
结果是 adult,求解惑
2023-03-28
最赞回答 / 慕少0598786
因为你写错了a=0b=0while True: if a > 1000: break if a % 2 == 0: b=b+a a=a+1print(b) 这样才对
2023-03-27