Write a function expanding(l) that takes as input a list of integer l and returns True if the absolute difference between each adjacent pair of elements strictly increases.
Answers
Answered by
5
Answer:
def expanding(l):
for i in range(len(l)-2):
if(l[i]>=l[i+1]):
return False
return True
Explanation:
parameter l as input here
Answered by
18
Answer:
def expanding(l):
for i in range (2,len(l)):
if(l[i]>l[i-1]):
a=l[i]-l[i-1]
else:
a=l[i-1]-l[i]
if(l[i-1]>l[i-2]):
b=l[i-1]-l[i-2]
else:
b=l[i-2]-l[i-1]
if a - b <=0:
return False
return True
Explanation:
Similar questions
Physics,
6 months ago
Math,
6 months ago
Computer Science,
6 months ago
Math,
11 months ago
Environmental Sciences,
1 year ago
Math,
1 year ago
Geography,
1 year ago