Last active
March 6, 2023 18:11
-
-
Save ROBOMASTER-S1/2e30b63ca0a869168406e1f917fcf067 to your computer and use it in GitHub Desktop.
Set Trix Python Program Example: Created by Joseph C. Richardson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by Joseph C. Richardson, GitHub.com | |
set1,set2=( | |
{'1','1','2','3','4','4','5','6','7','8','9','10'}, | |
{'A','B','C','D','E','E','F','G','H','H','I','J'} | |
) | |
convert1,convert2=list(set1),list(set2) | |
convert1,convert2=sorted(convert1),sorted(convert2) | |
convert1.extend(convert2) | |
print( | |
'Check the converted list values:\n\n'+str(convert1)+'\ | |
\n\nAll looks great!\n\nYou have',len(convert1),\ | |
'sorted list values in your convert1 extended list.\n' | |
) | |
reconvert=set(convert1) | |
print( | |
'Check the reconverted set values:\n\n'+str(reconvert)+'\ | |
\n\nAll looks great!\n\nYou have',len(reconvert),\ | |
'unsorted, randomized set values in your reconvert set.' | |
) | |
set1,set2,set3,set4=( | |
{1,2,3,4,5,6,7,8,9,10,4,2,10}, | |
{'1','1','2','3','4','4','5','6','7','8','9','10','20'}, | |
{'A','B','C','D','E','E','F','G','H','H','I','J'}, | |
{'Strawberries','Bananas','Apples','Oranges'}) | |
convert1,convert2,convert3,convert4=( | |
list(set1),list(set2),list(set3),list(set4)) | |
convert1,convert2,convert3,convert4=( | |
sorted(convert1),sorted(convert2), | |
sorted(convert3),sorted(convert4)) | |
convert1.extend(convert2) | |
convert1.extend(convert3) | |
convert1.extend(convert4) | |
reconvert=set(convert1) | |
print( | |
'Check the converted list values:\n\n'+str(convert1)+'\ | |
\n\nAll looks great!\n\nYou have',len(convert1),\ | |
'sorted list values in your convert1 extended list.\n' | |
) | |
print( | |
'Check the reconverted set values:\n\n'+str(reconvert)+'\ | |
\n\nAll looks great!\n\nYou have',len(reconvert),\ | |
'unsorted, randomized set values in your reconvert set.' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment