To create a set of numbers from 1 to N in Python, you can use a set comprehension or the built-in set() function.
In this example,
my_set = {x for x in range(1, 6)}
print(my_set)
{1, 2, 3, 4, 5}
In this example,
my_set = set(range(1, 11))
print(my_set)
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
In this tutorial, we learned How to create a Set of Numbers from 1 to N in Python language with well detailed examples.