Question: Write a program that does the following: It generates 10 random numbers, each in the range 1 through 1000. The program must be structured such

Write a program that does the following:

It generates 10 random numbers, each in the range 1 through 1000. The program must be structured such that it is easy to change the program code to generate as many random numbers as one wishes.

It prints each number and says for each number whether the number is odd or even.

After all numbers have been displayed, the program prints the number of even numbers and number of odd numbers generated.

Input 10 random numbers (generated within the program)

Output For each number, the number and whether it is odd or even

The number of odd numbers

The number of even numbers

The interaction must follow the style given below:

157 is odd

605 is odd

708 is even

705 is odd

738 is even

848 is even

467 is odd

377 is odd

825 is odd

148 is even

Number of odd numbers 6

Number of even numbers 4

1.1 Pseudocode

Answer the following questions.

There has to be a loop, as you might have concluded. If so, should it be a definite loop or indefinite loop? When should it stop? Sketch the loop here.

1

For the moment, assume that there is a way to generate a random number. Come up with a pseudocode statement for that.

3.

4.

Start

Stop

1.2 Implementation

Now code the program. You need to translate each line to Python code. To get the random numbers, note that the following code generates a number between 1 and 100.

random.randint (1, 100)

For this, you need to have the statement import random at the top of your program.

After coding, test your program at least a couple of times and verify that the output is correct. Show the Python code and demonstrate the working program to your instructor. Get his/her signature below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!