Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5 );
tup3 = "a", "b", "c", "d";


Ascending sort

Code Block
# set
pySet = {'e', 'a', 'u', 'o', 'i'}
print(sorted(pySet))

# dictionary
pyDict = {'e': 1, 'a': 2, 'u': 3, 'o': 4, 'i': 5}
print(sorted(pyDict))

# tuple
pyTyple = ('e', 'a', 'u', 'o', 'i')
print(sorted(pyTuple))



Descending sort

Code Block
# set
pySet = {'e', 'a', 'u', 'o', 'i'}
print(sorted(pySet, reverse=True))

# dictionary
pyDict = {'e': 1, 'a': 2, 'u': 3, 'o': 4, 'i': 5}
print(sorted(pyDict, reverse=True))

# tuple
pyTuple= frozenset(('e', 'a', 'u', 'o', 'i'))
print(sorted(pyTuple, reverse=True))


Set

Info

Unordered collections of unique elements

...