Subset | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Subset

Write a python script to print all possible subsets of r elements each from a given set of N elements. ::::::of r elements each:::::: Please anyone explain this part from the question.

13th Feb 2019, 7:40 AM
Susanta Paul
Susanta Paul - avatar
7 Answers
+ 3
set with n = 5 elements: [1, 2, 3, 4, 5] all possible subsets with r elements each (r = 3): [1, 2, 3] [1, 2, 4] [1, 2, 5] [1, 3, 4] (...)
13th Feb 2019, 7:45 AM
Anna
Anna - avatar
+ 4
You can use the documentation to learn more about modules and how certain functions work etc., but it's not really meant to be a tutorial. It's probably better to search for "python 3 itertools tutorial" and find sites like this: https://data-flair.training/blogs/python-itertools-tutorial/
13th Feb 2019, 8:27 AM
Anna
Anna - avatar
+ 3
Look into python's itertools module: https://docs.python.org/3/library/itertools.html#module-itertools (section "Combinatoric iterators")
13th Feb 2019, 7:58 AM
Anna
Anna - avatar
+ 1
Thank you so much But finding problems to create the program could you please create the program
13th Feb 2019, 7:55 AM
Susanta Paul
Susanta Paul - avatar
0
In python documentation can we learn basic to advanced python? Anna
13th Feb 2019, 8:06 AM
Susanta Paul
Susanta Paul - avatar
0
Ok thanks
13th Feb 2019, 8:57 AM
Susanta Paul
Susanta Paul - avatar
0
Anna from where i can learn data structures and algorithms in python?
13th Feb 2019, 9:23 AM
Susanta Paul
Susanta Paul - avatar