Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON QUESTION - Iterate through the list and determine how many values were ODD and how many were EVEN in python. Print out the count

PYTHON QUESTION - Iterate through the list and determine how many values were ODD and how many were EVEN in python. Print out the count for each type at the end of the program and what percentage it was of the total.

# bring in randomness cause we need it in our lives import random import percentage as percentage def generate_random_int_list(max_length, upper_bound): # generate random length between 2 and max_length list_length = int(random.uniform(2, max_length)) # given the length above, sample the Natural Numbers up to upper_bound that many times vars = random.sample(range(upper_bound), list_length) # return the generated list return vars # generate two random lists of integers max_length = 100; upper_bound=1000000 nums = generate_random_int_list(max_length, upper_bound) # see how long this list is print("The list contains "+str(len(nums))+" values total.") 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago