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

What my output was that I need to be solved:

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:20
Write a program that prompts the user to input a string. the program then uses the function substr to remove all the vowels from the string. for example, if str = "there", then after removing all the vowels, str = "thr". after removing all the vowels, output the string. your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
For the following example of making a peanut butter and jelly sandwich, identify which are inputs, processes, or outputs: bread scooping and spreading peanut butter plate scooping and spreading jelly finished sandwich putting two pieces of covered bread together dirty plate crumbs
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Which one of the following functions is not available on the autosum tool? sum average if max
Answers: 3
question
Computers and Technology, 25.06.2019 01:30
The study of how to design software, solve problems such as computer security threats, or come up with better ways of handling data storage
Answers: 1
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
Mathematics, 26.01.2021 01:00
question
Mathematics, 26.01.2021 01:00
question
Chemistry, 26.01.2021 01:00
question
Biology, 26.01.2021 01:00
Questions on the website: 13722361