Question

Python Implement function allEven() that takes a list of integers and returns True if all integers...

Python

Implement function allEven() that takes a list of integers and returns True if all integers in the list are even, and False otherwise.

>>> allEven([8, 0, -2, 4, -6, 10])

True

>>> allEven([8, 0, -1, 4, -6, 10])

False

Homework Answers

Answer #1

def allEven(a):
for one in a:
if one%2 == 1: # if odd, returning False
return False
return True

print(allEven([8, 0, -2, 4, -6, 10]))
print(allEven([8, 0, -1, 4, -6, 10]))

# Hit the thumbs up if you are fine with the answer. Happy Learning!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Implement function reverse that takes a 2D list (a list of list of integers) and returns...
Implement function reverse that takes a 2D list (a list of list of integers) and returns a new 2D list where the items in each row are in reverse order. You maynot use slicing. You may not modify the input list. The returned list should be completely new in memory – no aliases with the input 2D list. From list methods, you may use only the .append(). Examples: reverse([[1,2,3],[4,5,6]])       ->    [[3,2,1],[6,5,4]] reverse([[1,2],[3,4],[5,6]])     ->    [[2,1],[4,3][6,5]] True False In python please
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a...
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a list of integers representing how many integers in each sublist of the original were divisible by 5. Examples: >>> count_div5([[5, 3, 25, 4], [46, 7], [5, 10, 15]]) [2, 0, 3] >>> count_div5([]) [] >>> count_div5([[-20, 10, 2, 4, 5], [], [5], [8, 25, 10], [6]]) [3, 0, 1, 2, 0]
Implement function subset that takes a set of positive integers and returns asubset of it that...
Implement function subset that takes a set of positive integers and returns asubset of it that includes only those numbers that can form a sequence. It's ok if more than one sequences co-exist in the subset. You may not use lists, tuples, strings, dictionaries; only set functions/methods are allowed. Examples: subset({0,4,11,5,3,2,7,9})    ->    {4,5,3,2} subset({3,1,6,8,2,12,9})      ->    {3,1,2,8,9} True False In Python Please
Implement function swap that takes a 2D list (a list of list of integers) and modifies...
Implement function swap that takes a 2D list (a list of list of integers) and modifies it in-place by swapping the first element in each row with the last element in that row. The return value is None. You may not use slicing. You maynot use any list method like append, insert, etc. Modification must be in-place, you may not move the list itself or any of its sublists to a new memory location. Examples: reverse([[1,2,3],[4,5,6]])        ->    [[3,2,1],[6,5,4]] reverse([[1,2,3,4],[5,6,7,8]])    ->    [[4,2,3,1],[8,6,7,5]]...
Implement in python a function avg_val(lst), which returns the average value of the elements in list....
Implement in python a function avg_val(lst), which returns the average value of the elements in list. For example, given a list lst: [19, 2, 20, 1, 0, 18], the function should return 10. The name of the method should be avg_val and the method should take one parameter which is the list of values to test. Here is an example call to the function print(avg_val([19, 2, 20, 1, 0, 18]))
design an algorithm in a c++ function that takes as input a list of n integers...
design an algorithm in a c++ function that takes as input a list of n integers and find the location of the last even integer in the list or returns 0 if there are no even integers in the list
Create a function which returns the number of odd integers in a list (python)
Create a function which returns the number of odd integers in a list (python)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT