A programmer has started to write a program using Python.
Their program is shown in Figure 6.
The program should generate and output 10 numbers, each of which is randomly selected from the numbers in a data structure called numbers
.
The program uses the random
module.
For example, random.randrange(0, 8)
would generate a random integer between 0 and 7 inclusive.
One possible output from the finished program would be 11, 14, 14, 42, 2, 56, 56, 14, 4, 2
Line numbers are included but are not part of the program.
Figure 6
1 import random
2 numbers = [ 11, 14, 56, 4, 12, 6, 42, 2 ]
3 count = 0
4 while count < 10:
5 count = count + 1
6 number = random.randrange(0, 8
7 print(numbers[count])
What type of data structure is the variable numbers?
Did this page help you?