Tuesday, April 23, 2024

📑 A Ternary Numeral System

📑 Task

1) What result will this program produce?
2) Rewrite this function for the numeral system with the base 3 (ternary)

📑 Answer

1) True
2)

📑 Recursive Infinite Generators

📑 Task

1) What is the last number the program will print?
2) What object appears when this function is applied
3) Can you write a program for an infinite generator of fibonacci numbers
without recursion but limit the number of iterations?

📑 Answer

1) 34
2) It is a recursive infinite generator
3)

📑 A Series of Variables

📑 Task

1) What will the program print for each case?
2) How to change f_string_y in the program so that variables y0, y1, y2 become global

📑 Answer

1) x0=1 x1=2 x2=4 True and y0=1 y1=2 y2=4 False
2)

📑 Function Dictionary

📑 Task

1) What object is created by the first line of the program?
2) Rewrite the function so that the numbers from 0 to 3 are raised to the 2nd power

📑 Answer

1) The result is a function that creates a dictionary of functions
2)

📑 Copying Lists

📑 Task

1) What will the program print?
2) Make a list of identical elements and copy this list
so that the result of the last three lines looks different:
[[1], [], []] [[2], [], []]

📑 Answer

1) 2 lists of empty lists: [[], [], []] [[], [], []]
2 identical lists of elements: [[1, 2], [1, 2], [1, 2]] [[1, 2], [1, 2], [1, 2]]
2)