Computer Science Homework Help

CPS 470 570 Python Random Integers and Threads Code

Get Your Custom Essay Written From Scratch
We have worked on a similar problem. If you need help click order now button and submit your assignment instructions.
Just from $13/Page
Order Now

Write python code to complete the following tasks. Global variables are not allowed.
Only constants could be global.

1. Insert 20 random integers in the range [10, 30] into a queue named jobs.
Print those random integers on the screen.

2. In main(), create 5 threads, each having a unique ID (e.g., thread 1’s ID
is 1, thread 2’s ID is 2, and so on).

3. Each thread gets an integer from the queue jobs. If this integer is unique,
this thread prints the integer on the screen, and increases countUniques by 1
(countUniques’s initial value is 0).

4. In main(), after all threads finish work, print countUniques’s value
on the screen.
[If jobs has 20 random integers but there are 15 unique ones, then we should see
15 on the screen.]