create a table that counts the number of times each integer from 1 to 100 appears in an array, including a row for the numbers between 1 to 100 that have 0 occurances in r

main.py
import numpy as np

# Create an array with random integers between 1 and 100
array = np.random.randint(1, 101, 1000)

# Create a frequency table counting the occurrences of each integer from 1 to 100
unique, counts = np.unique(array, return_counts=True)
frequency_table = dict(zip(unique, counts))

# Create a table with frequencies of numbers from 1 to 100, including those with 0 occurrences
for i in range(1, 101):
    count = frequency_table.get(i, 0)
    print(f"Number: {i}, Count: {count}")
498 chars
14 lines

gistlibby LogSnag