Answer to Question #209984 in Python for Mia

Question #209984

Write a python program to create an array of 10 integers and display the array items. The array should be populated with random integers from 10 to 50. The program should also display separately all the even numbers within the array.


1
Expert's answer
2021-06-23T07:01:44-0400
import random

arr = [random.randint(10, 50) for _ in range(10)]
print("Array: ", arr)
even_arr = list(filter(lambda x: x % 2 == 0, arr))
print("Even numbers: ", even_arr)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS