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 11:30
What does a cascading style sheet resolve a conflict over rules for an element? a. the rule affecting the most content wins b. the rule affecting the most content loses c. the rule with the most specific selector loses d. the rule with the most specific selector wins
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
Which tab should you open to find the option for adding a header?
Answers: 1
question
Computers and Technology, 23.06.2019 13:00
In excel - calculate the actual increase/decrease from first quarter to the second quarter then subtract subtract first quarter value from second quarter total then divide result by first quarter value
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
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
Physics, 03.06.2021 02:40
question
Biology, 03.06.2021 02:40
question
Mathematics, 03.06.2021 02:40
question
Health, 03.06.2021 02:40
question
Mathematics, 03.06.2021 02:40
Questions on the website: 13722362