Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IN PYTHON 1. function takes in a list, and returns a Boolean value based on the

ID: 3930999 • Letter: I

Question

IN PYTHON

1. function takes in a list, and returns a Boolean value based on the contents of the list. If all elements of the list are identical, the function returns True. If even one element is different, the function returns False.

2. function takes in a list, and returns a Boolean value based on the contents of the list. If all elements of the list are different, the function returns True. If two elements (or more) are the same, the function returns False.

3. function takes in a list, and returns a Boolean value based on the contents of the list. If all elements of the list are ordered from smallest to largest, the function returns True. If any elements are out of order (including if the list is ordered from largest to smallest), the function returns False. MUST BE IN PYTHON

Explanation / Answer

Ans.1)

list=[1, 1, 1, 1, 1] #list taken just for input
def listContent(list): #function definition
   i=0

   while(i<len(list)-1):
   if(list[i]==list[i+1]): //alternate element must be same
   i=i+1   
   if(len(list)-1==i): //if we traveresed to the last element of the list it means all list element are same
   return True
   else :
   return False
   break
  

print(listContent(list))  


****OUTPUT*****
True
****OUTPUT*****