Thursday, June 13, 2024

📑 Custom Dictionaries

📑 Task

1) Describe the properties of the created custom dictionary
2) Define another dictionary in a similar way but with other properties
Your dictionary can have a list as a value only where it's necessary
That is, only where several values correspond to one key
in the definding process

📑 Answer

1) - **Key-Value Mapping**:
The dictionary maps integer keys to their corresponding binary string
representation, padded with leading zeros to a fixed length of 16 bits.
- **Automatic Conversion**:
When setting a new key-value pair using the `__setitem__` method,
the integer key is automatically converted to its binary string
representation before being stored in the dictionary.
- **Inheritance**:
By inheriting from `UserDict`, the `IntBinDict` class inherits
all the methods and properties of the built-in `dict` type,
allowing for seamless integration with existing Python code
that expects a dictionary-like object.
2)

Tuesday, June 4, 2024

📑 Items not Defined in the Dictionary

📑 Task

1) What element removing is fundamentally different from
all others for dictionary in this code fragment?
2) Suggest programs to access elements that do not exist
in the dictionary without causing an error

📑 Answer

1) Deleting "11" is different from all others, since such a key
was not defined in the dictionary
2)

Friday, May 31, 2024

📑 Pairs in Strings

📑 Task

1) What does this program calculate?
2) Suggest a program for easier calculation of this indicator

📑 Answer

1) This program calculates the maximum number of pairs of the same letters
in a given string, taking into account all possible shifts of the string.
2)

Monday, May 27, 2024

📑 Coroutine Math Functions

📑 Task

1) What is the name of the special type of functions
(the second one in the given code fragment)?
Why do we add "None" to the beginning of the list of angle measurements?
2) Modify this function so that it collects values and does not print them out

📑 Answer

1) This is a coroutine function
We must initialize the coroutine and prepare it to accept values
so we are starting with None
2)

Sunday, May 26, 2024

📑 List Methods and Generators

📑 Task

1) What values do the generators calculate in this case?
What will the program print?
2) Give a similar example using generators and list methods,
where it is impossible to use lists with completely different values

📑 Answer

1) The outputs: [21, 'a', 21] and [2, 1, 1, 0, 0, 1, 2, 2, 1]
Both generators calculate their values in the first list
based on information from the second one
2)

Saturday, May 25, 2024

📑 Applying Class Methods

📑 Task

1) What value will "population" be after running the code?
2) Modify the class code so that its examples can transfer any indicators
to each other (energy, objects collected during the task, etc.)

📑 Answer

1) It will be zero again
2)

Thursday, May 23, 2024

📑 Table Formatting

📑 Task

1) Will the code throw an error due to
different lengths of nested components?
2) Suggest a code snippet that will turn nested lists
into tabs with html markup

📑 Answer

1) No, this function provides for filling missing values
with spaces when printing
2)