第二十题这样的,实在是不会写,求帮助
你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)
def fun(lst):
i = len(lst) // 2
return (lst[i] + lst[-i-1])/2
print(fun([1,2,3,4,5]))
print(fun([1,2,3,4]))
def function(x):
length = len(x)
if (length % 2)== 1:
z=length // 2
return x[z]
else:
return (x[length//2]+x[length//2-1])/2
import math
def fun(lst):
return lst[math.ceil(len(lst)/2-1)]
望采纳~😁