Answer:
Following are the function to the Python Programming Language.
#define a function to read or crates the list
def GetUserValues():
my_list=[]
n=int(input("Enter range: "))
for i in range(n):
my_list.append(int(input(" :")))
return my_list
#define a function to check the elements of the list
def IsListEven(mylist):
#set the for loop
for i in range(len(mylist)):
#set if condition to check odd number
if mylist[i]%2 !=0:
#if condition is true retun false
return False
#otherwise return true
return True
#define a function to check the elements of the list
def IsListOdd(mylist):
#set the for loop
for i in range(len(mylist)):
#set if condition to check even number
if mylist[i]%2==0:
#if condition is true retun false
return False
#otherwise return true
return True
#set variable to store list
l=GetUserValues()
#set if condition to check the function is true
if IsListOdd(l)==True:
#then, print the message
print("all odd")
#set elif condition to check the function is true
elif IsListEven(l)==True:
#then, print the message
print("all Even")
else:
#otherwise print message.
print("not even or odd")
<u>Output:</u>
Enter range: 5
:2
:4
:6
:8
:10
all Even
Explanation:
Here, we define a function "GetUserValues()" and inside the function.
- Set the list data type variable "my_list" then, get input from the user in the variable "n".
- Set the for loop which starts from 0 and end at the variable "n" then, get input from the user and appends inputs in the variable "my_list".
- Then, we return list and close the function.
Then, we set a function "IsListEven()" and pass an argument "mylist" to check the elements is even or not, if the list elements is even then, return true otherwise, return false.
Then, we set a function "IsListOdd()" and pass an argument "mylist" to check the elements is odd or not, if the list elements is odd then, return true otherwise, return false.
Finally, we call and store the function in the variable "l" then, set conditions to check the list is even print "all even", if the is odd "all odd" otherwise, print "not even or odd".