Python Practice › Set Programs › Program 44

Set of odd numbers

EasySet Programs · 44 of 48

Write a Python program to create a set of odd numbers from 1 to 20.

Advertisement
Output
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19}

Approach

  1. set(range(1, 21, 2)).

Solution

Python
print(set(range(1, 21, 2)))
Output
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19}

Learn the concept

New to this topic? Read the lesson, then come back.

More set programs

← All 48 Set Programs

Leave a Comment