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)

Tuesday, May 21, 2024

📑 Object Similarity

📑 Task

1) Can you explain difference between the follow objects:
x_same, x_copy, x_equal?
2) Write a function that compares two lists based on the following parameters:
a) is the list length the same,
b) do all unique elements match,
c) whether the composition of the list as a whole is the same,
d) are the elements arranged in the same order,
e) whether they have the same address in memory.
Apply it to the indicated objects

📑 Answer

1) a) x_same and x contain from the same elements,
but they are different and independent objects
b) x_equal refers to the same list object as x,
so they share the same memory address
c) x_copy refers to a new list object created by making
a shallow copy of x, so x_copy is a different object
with the connection to the original list because of
the nested mutable component []
2)

Sunday, May 19, 2024

📑 Count in Two

📑 Task

1) Will the functions count1() and count2() count events independently of each other?
2) How can we define other Python objects that allow us
to count events in programs using the same rule?
For example, classes or generators

📑 Answer

1) Yes, the functions will count independently of each other
depending on the number of calls
2)

Saturday, May 18, 2024

📑 Max Product of Three

📑 Task

1) Find a mistake in the process of recursion the function
for calculating the maximum product of three numbers in the list
2) Suggest a possible decision to build a recursive function

📑 Answer

1) Incorrect recursion logic: if the list becomes longer by one element,
then all the indices of the elements that give the maximum product
could be changed, not only one index
2)

Sunday, May 12, 2024

📑 Referring to the Same Object

📑 Task

1) Will the result of printing the values for the functions f1 and f2
be the same in all cases?
2) Print out the values of the function f2 at x = 1, 2, 3 so
that the result will be the same for all x

📑 Answer

1) When printed in a loop, the functions' values will be equal
For f1 the default list-argument changes
(it was set when the function was defined)
For f2 the same list-variable changes
(it was set as a global variable)
When printed by the generator, the functions' values become different
f1 continues to expand the default list-argument
f2 begins to expand the empty list-variable again
2)

Saturday, May 11, 2024

📑 Neuron Activations

📑 Task

1) Can you describe the goals of creating this type of objects?
2) Try to modify this class so that it becomes more
multifunctional and has several activation methods

📑 Answer

1) This Neuron class aims to provide a foundation for understanding how
individual neurons process input data and produce output in a neural network
2)