subject

Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Ex: If the input is:
5
2
4
6
8
10
the output is:
all even
Ex: If the input is:
5
1
3
5
7
9
the output is:
all odd
Ex: If the input is:
5
1
2
3
4
5
the output is:
not even or odd
Your program must define and call the following two functions. is_list_even() returns true if all integers in the list are even and false otherwise. is_list_odd() returns true if all integers in the list are odd and false otherwise.
def is_list_even(my_list)
def is_list_odd(my_list)
My Current Code:
def GetUserValues():
myList=[]
n=int(input())
for i in range(n):
myList. append(int(input()))
return myList
def IsListEven(myList):
for i in range(len(myList)):
if myList[i]%2 !=0:
return False
return True
def IsListOdd(myList):
for i in range(len(myList)):
if myList[i]%2==0:
return False
return True
list=GetUserValues()
if IsListOdd(list)==True:
print("all odd")
elif IsListEven(list)==True:
print("all even")
else:
print("not even or odd")

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:00
Meenu wants to create a high quality drawing in a variety of colours. which device should she use for the same?
Answers: 1
question
Computers and Technology, 22.06.2019 23:00
Which factor is the most important when choosing a website host? whether customers will make secure transactions the number of email accounts provided the purpose of the website the quality of the host control panel
Answers: 3
question
Computers and Technology, 23.06.2019 17:00
What does the faves button do? a. users mark a web page as a favorite b. leads other readers to favor a specific page c. readers sort and align their favicons, or favorite icons d. leads users to a message board where they can post questions
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
You draw two cards from a standard deck of 52 cards, but before you draw the second card, you put the first one back and reshuffle the deck. (a) are the outcomes on the two cards independent? why?
Answers: 3
You know the right answer?
Write a program that reads a list of integers, and outputs whether the list contains all even number...
Questions
question
English, 05.05.2021 20:00
question
Mathematics, 05.05.2021 20:00
Questions on the website: 13722367