116k views
18 votes
using a timer to generate a random number, develop a program that displays random numbers between 1 and 47 (or whatever) for your state's lottery

User Kunif
by
4.0k points

1 Answer

7 votes

Answer:

Step-by-step explanation:

The following code is written in Python. It creates a variable that detects the current time. Then it loops through a range of numbers and chooses the last random number after 2 seconds. Finally, it prints that number to the screen. This function can be called countless times depending on the number of state lottery numbers needed.

import random

import time

start_time = time.time()

while time.time() - start_time < 2:

lottery_number = random.randint(0, 48)

print(lottery_number)

User Mikel Tawfik
by
3.7k points