Converting to Set in Python

To convert a data type to a set, it should be passed to the set function parameter.

Let's make a set out of a string:

pythontxt = 'abcde'
st = set(txt)

print(st) # {'a', 'b', 'c', 'e', 'd'}

Now let's transform the list into a set:

pythonlst = [1, 2, 3, 4]
st = set(lst)

print(st) # {1, 2, 3, 4}

However, when transforming a dictionary, only its keys will be included in the set:

pythondct = {
  'a': 1,
  'b': 2,
  'c': 3
}

st = set(dct)
print(st) # {'c', 'b', 'a'}
Задание 1

Two lines are given:

pythontxt1 = '1234'
txt2 = '5678'

Make one set out of them.

Задание 2

A tuple is given:

pythontlp = ('a', 'b', 'c', 'd')

Convert it to a set.

Задание 3

Given a dictionary:

pythondct = {
  1: 'ab',
  2: 'cd',
  3: 'ef',
  4: 'jh'
}

Make two sets out of it. One set will contain the dictionary keys, and the other set will contain the values.