name=['Alice', 'Bob', 'Candy', 'David', 'Ellena']
names = [];
scores=[89,72,88,79,99]
score=[89,72,88,79,99]
scores.sort()
scores.reverse()
x = 0
y = 0
for ls in scores:
y=0;
for l in score:
if ls == l:
names.append(name[y])
y = y+1
x = x+1
print(names)
names = [];
scores=[89,72,88,79,99]
score=[89,72,88,79,99]
scores.sort()
scores.reverse()
x = 0
y = 0
for ls in scores:
y=0;
for l in score:
if ls == l:
names.append(name[y])
y = y+1
x = x+1
print(names)
2023-02-08
T = ('Alice', 'Bob', 'Candy', 'David', 'Ellena')
# 通过下标的方式访问元素
print(T[0]) # ==> Alice
print(T[4]) # ==> Ellena
# 切片
print(T[1:3]) # ==> ('Bob', 'Candy')
# 通过下标的方式访问元素
print(T[0]) # ==> Alice
print(T[4]) # ==> Ellena
# 切片
print(T[1:3]) # ==> ('Bob', 'Candy')
2023-02-03
在计算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-02-02
def func(**kwargs):
s = 0
for i in n:
print('name:{},gander:{},age:{}'.format(n[s],g[s],a[s]))
s += 1
n = ['Alice','Bob','Candy']
g = ['F','M','F']
a = ['18','19','20']
func(names = n,gander = g,age = a)
s = 0
for i in n:
print('name:{},gander:{},age:{}'.format(n[s],g[s],a[s]))
s += 1
n = ['Alice','Bob','Candy']
g = ['F','M','F']
a = ['18','19','20']
func(names = n,gander = g,age = a)
2023-01-10
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if (s1.isdisjoint(s2) == False):
for i in s2:
if i in s1:
print(i)
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if (s1.isdisjoint(s2) == False):
for i in s2:
if i in s1:
print(i)
2023-01-04
# coding=utf-8
def sub_sum(L):
odd = 0
even = 0
for x in L:
if x%2 == 0:
even += x
else:
odd += x
return odd,even
print(sub_sum([1,2,3,4,5,6]))
def sub_sum(L):
odd = 0
even = 0
for x in L:
if x%2 == 0:
even += x
else:
odd += x
return odd,even
print(sub_sum([1,2,3,4,5,6]))
2023-01-04