# (8)
def manhadun(lstA, lstB):
distanceM = 0
for i in range(2):
distanceM += lstB[i] - lstA[i]
return distanceM
distanceM = 0
lstA = []
lstB = []
for i in range(2):
pointA = int(input("pointA:"))
pointB = int(input("pointB:"))
lstA.append(pointA)
lstB.append(pointB)
print(lstA)
print(lstB)
distanceM = manhadun(lstA, lstB)
print(distanceM)
print(sum(map(lambda x, y: abs(x - y), lstA, lstB)))
# (9)
from functools import reduce
lstA = []
lstB = []
for i in range(3):
a = int(input("Please input numberA:"))
lstA.append(a)
for i in range(3):
b = int(input("Please input numberB:"))
lstB.append(b)
print(reduce(lambda x, y: x|y, [set(lstA), set(lstB)]))
#(10)
a1 = int(input("Please input a number(a1):"))
q = int(input("Please input a number(q in range(2, 37)):"))
n = int(input("Please input a number(n):"))
Sn = a1 * (1-q**n) / (1-q)
print(int(Sn))
#(11)
Str = input("Please input some strings:")
s = dict()
for i in Str:
s[i] = s.get(i, 0) + 1
mostCommon = max(s.items(), key=lambda item: item[1])
print(mostCommon)
运算符,内置函数,序列基本用法(2)
最新推荐文章于 2021-05-07 21:41:54 发布