human
Check if an array is increasing or decreasing | Function to check the type of the array.
If the first two and the last two elements of the array are in increasing order.
If the first two and the last two elements of the array are in decreasing order.
If the first two elements of the array are in increasing order and the last two elements of the array are in decreasing order.
If the first two elements of the array are in decreasing order and the last two elements of the array are in increasing order.
Driver code"
How can the above be solved in Python?
 Can you provide a code to check if an array is increasing or decreasing and the other steps required?
assistant
#Here is code to check if an array is increasing or decreasing and the other steps required.
 def checkType ( arr , n ) :
	if ( arr [ 0 ] <= arr [ 1 ] and arr [ n - 2 ] <= arr [ n - 1 ] ) :
		print ( " Increasing " ) ;
	elif ( arr [ 0 ] >= arr [ 1 ] and arr [ n - 2 ] >= arr [ n - 1 ] ) :
		print ( " Decreasing " ) ;
	elif ( arr [ 0 ] <= arr [ 1 ] and arr [ n - 2 ] >= arr [ n - 1 ] ) :
		print ( " Increasing ▁ then ▁ decreasing " ) ;
	else :
		print ( " Decreasing ▁ then ▁ increasing " ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 2 , 3 , 4 ] ;
	n = len ( arr ) ;
	checkType ( arr , n ) ;