Lab08codepy Please help me the Python program Write a Python

Lab08code.py

Please help me the Python program.

Write a Python program that will: a. fill a n = 25 element array (list) with integers in the range 25 -50 b. print out the values c. print out the number of even integers Python code template to consider: import random print(\'1...\', random.randint (10, 15)) myArray = [] print(\'2...\', myArray) myArray.insert(0, 11) myArray.insert(1, 22) print(\'3...\', myArray) if (myArray [0] % 2 == 0): print(myArray[0], \"the random integer is EVEN\") else print (myArray[0], \"the random integer is ODD\") OUTPUT 1... 14 2... [] 3... [11, 22] 11 the random integer is ODD You should use an iterative operator (for, while etc.) rather than 25 individual lines of code to populate the array. To determine the number of even integers examine the array to see if the element is even (see above), and maintain a running total Rerun your code for accuracy

Solution

import random
myArray=[]
for i in range (25):
myArray.insert(0, random.randint(25,50))
print \"The Array is\ \"
print myArray
print \"\ Even numbers in Array are:\ \"
for i in myArray:
if (i%2==0):
print i

Lab08code.py Please help me the Python program. Write a Python program that will: a. fill a n = 25 element array (list) with integers in the range 25 -50 b. pri

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site