Python Practice › Set Programs › Program 10

Is one set a subset of another?

EasySet Programs · 10 of 48

Write a Python program to check whether one set is a subset of another.

Advertisement
Input
{2, 3}, {1, 2, 3, 4}
Output
True True False

Approach

  1. <= or issubset(); < checks a proper subset.

Solution

Python
small, big = {2, 3}, {1, 2, 3, 4}print(small <= big, small < big, big <= small)
Output
True True False

Learn the concept

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

More set programs

← All 48 Set Programs

Leave a Comment