Code the algorithm on the home page of this unit. Test it until you are satisfied that it works properly.
A teacher stores student names in an array as follows:
| "Alex" | "Janice" | "Nicki" | "Jay" | "Maya" | "Bob" | |
| index | 0 | 1 | 2 | 3 | 4 | 5 |
She needs a computer program that will select 1 random name.
Write this program. Think logically! This is an easy question to over-complicate!
A computer program generates 1000 random numbers between 0 and 1000 and stores them in an array:
arr = [ ]
for i in range(1000):
rand = random.randint(0,1000)
arr.append(rand)
print(arr)
It then counts how many of the numbers are odd and how many are even and displays the result.
Write this program.
Note: see how useful Python's append function is when working with arrays!.