0% found this document useful (0 votes)
918 views3 pages

CYB 130 Week 4 Python LAB 5.24 Even Odd Values in A List

The document advertises providing complete course papers and assignments for $150, including up to 5 papers, 1 discussion question response, and 1 quiz. It instructs customers to email [email protected] to purchase and submit the papers without changes.

Uploaded by

CHRIS D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
918 views3 pages

CYB 130 Week 4 Python LAB 5.24 Even Odd Values in A List

The document advertises providing complete course papers and assignments for $150, including up to 5 papers, 1 discussion question response, and 1 quiz. It instructs customers to email [email protected] to purchase and submit the papers without changes.

Uploaded by

CHRIS D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Don’t have Time to write your papers

We can provide complete course New Papers


at just $150 (upto 5 Papers + one DQ
Response +Quiz)
 

You can submit the papers without any changes


 
Just email us at [email protected]

def get_user_values():
n = int(input())
lst = []
for i in range(n):
lst.append(int(input()))
return lst

def is_list_even(my_list):
for num in my_list:
if num % 2 == 1:
return False
return True

def is_list_odd(my_list):
for num in my_list:
if num % 2 == 0:
return False
return True

if __name__ == '__main__':
lst = get_user_values()
if is_list_even(lst):
print("all even")
elifis_list_odd(lst):
print("all odd")
else:
print("not even or odd")
Code 2
#define is_list_even function that takes list return true if all elements are even else return false

def is_list_even(my_list):
for i in my_list:#for every element of list
if i%2!=0:#check number is even or not
return False#return False if any of number is not even
return True

#define is_list_odd function that takes list return true if all elements are odd else return false

def is_list_odd(my_list):
for i in my_list:#for every element of list
if i%2==0:#check number is odd or not
return False#return False if any of number is not odd
return True

if __name__ =='__main__':
a=[]
n=int(input())#Getting size of list
for i in range(n):#for every element append it to list
a.append(int(input()))
if (is_list_even(a)==True):
print ("all even")#print all even when is_list_even method returns true
elif (is_list_odd(a)==True):
print ("all odd")#print all odd when is_list_odd method returns true
else:
print ("not even or odd")#print this for other cases

Code 3
def GetUserValues():

myList = []

s = input()

while(s):

myList.append(int(s))

s = input()

return myList

def IsListEven(myList):

for x in myList:
if x%2==1:

return False

return True

def IsListOdd(myList):

for x in myList:

if x%2==0:

return False

return True

def main():

myList = GetUserValues()

if(IsListEven(myList)):

print("all even")

elif(IsListOdd(myList)):

print("all odd")

else:

print("not even or odd")

main()

You might also like