Generation

generate functionTue, 02 May 2023

realizar una función que genere 100 números aleatorios y sumar sus cuadrados usando hilos

import threading import random import time def sum_random_numbers(): random_list = [] for _ in range(100): random_list.append(random.randint(1, 100)) print(sum(random_list)) if __name__ == '__main__': threads = [] for i in range(10): thread = threading.Thread(target=sum_random_numbers) threads.append(thread) thread.start() for thread in threads: thread.join()

Questions about programming?Chat with your personal AI assistant