Computer Science, asked by vcharithacherry, 11 months ago

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 kolluriabhisehk54
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 aparnaagrawal468
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