Computers and Technology

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")

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:30, gracie2492
What result from the passage of this amendment
Answers: 1
image
Computers and Technology, 22.06.2019 06:40, EricaLSH7624
Match the personality traits with their description
Answers: 2
image
Computers and Technology, 22.06.2019 18:30, lizz1228
Kto rozmawia z clamentain przez krótkofalówke w the walking dead w 4 epizodzie
Answers: 1
image
Computers and Technology, 22.06.2019 19:00, SoccerHalo
How is the number 110 written when expanded out to place values in the base 2 (binary) number system? options: 2 x 4 + 3 x 2 + 4 x 1 1 x 2 + 1 x 2 + 0 x 2 1 x 100 + 1 x 10 + 0 x 1 1 x 4 + 1 x 2 + 0 x 1
Answers: 1
Do you know the correct answer?
Write a program that reads a list of integers, and outputs whether the list contains all even number...

Questions in other subjects:

Konu
Chemistry, 16.10.2019 21:30