  Python
 


   Python        ,        .       Python          .               ?       ,     ,       .   ,          . ,     ,    ,   ,       .        -,   .





 

  Python





 1:   ?



1.1.     

   ,     .               .       ,    ,     .                 .

   ,     ,     .    ,     - .               .

       .        ,   .        ,   .  ,    ,     .

          .          .            .

       ,     .   ,             . ,    ,        .

          ,  ,   ,         .          ,           .

       ,                   .      ,          .


1.2.        

                    .         ,      ,     .  ,        .

  ,        .   ,  ,    .     ,   ,  ,       .



      :

1.  :

            .                 .       ,          .

           .   ,       ,     ,    .   ,    ,   .

     .          ,        .       ,   ,        .

     ,         .       ,           .

  ,            .   ,     ,  ,           .

          .  ,           .      ,              .

2.   : 

          .           ,       .      ,         .

           .  ,         ,      ,     .     ,        ,           .

         . ,           ,     .         ,         .

 ,             .      ,         .

            .     ,            .        ,           .

3.    : 

          .          ,      .       ,      ,    ,     ,          .

             .        ,         .               .

            ,   ,      .     ,              .

          .               .             .

            .     ,            .         ,       .

4.    : 

             .          ,      .       ,      .

       ,          .       ,          .            .

 ,   ,   ,     ,    .     ,     ,     -   .       ,    , -   .

      ,         ,          .

          ,       .                    .

5.     : 

             . ,      ,    ,   ,   ,   .                .

     ,        .  ,            .          ,    .

,            .      ,    ,          .     ,    ,   .

          ,     .           .              .

 ,            .     ,          .                  .

     ,         .       ,       ,    .


1.3.    ?

             :

1.  :

          .       ,        ,     .             ,    .

     ,        . ,    ,  ,    ,                 .         ,       ,        -    .

  ,    ,      .      ,              .           ,         .

           .           ,        .

2.  :

        ,    .       .             .         , ,   ,          .

          ,        .   ,     ,       .         ,    -.

           ,       .          .  ,             ,     .

3.  : 

        .           ,        .

   ,            .       ,        .          ,         -   .

 ,        .          ,     . ,   ,      .

 ,      ,           .   ,        .

4.  : 

      ,         .           .  ,       ,         .

     ,       ,     .      ,    , , ,       .

 ,         .  ,     ,      ,     .       , ,   ,      .

,      ,       ,      .     ,               .

5.  : 

          .            .       ,         .

      .     ,       .  ,             ,      .

 ,        ,         .         ,    ,      .

6.   : 

         .       ,     ,     . ,   ,     ,     .

       .     ,       .  ,      ,       .

          .     ,     ,      .  ,                .

,          ,       .

7.  : 

             .         .      ,         .

-,       .         .              .

-,     ,      .      ,            .

 ,   -      .              .    ,       ,         .

 ,      ,      ,   -.   ,          .

8.    : 

          .        ,         .    ,    .

-,        .  ,     ,   ,     .      ,    .        ,     .

-,          .          .         ,           .

 ,     ,   ,        .        ,       .

 ,         .         ,      ,   .            .

       ,       ,    .        ,       .




 2:    



2.1.   Python

  Python      ,      .        Python,          :

1.  `math`

 `math`  Python     ,       .      ,    :

`math.sqrt(x)`:       `x`.

`math.sin(x)`, `math.cos(x)`, `math.tan(x)`:    ,     `x`,  `x`   .

`math.log(x)`, `math.log10(x)`:          10  `x`.

`math.exp(x)`:      `x`.

`math.pow(x, y)`:     `x`   `y`.

`math.pi`  `math.e`:      ?   e .

`math.factorial(x)`:      `x`.

      `math`          Python.               ,     .

      `math`:

```python

import math

#   

x = 25

sqrt_result = math.sqrt(x)

print(f"   {x} = {sqrt_result}")

#       

angle_rad = math.radians(45) #    

sin_result = math.sin(angle_rad)

cos_result = math.cos(angle_rad)

print(f"  45  = {sin_result}")

print(f"  45  = {cos_result}")

#   

y = 2.71828 #    

ln_result = math.log(y)

print(f"   {y} = {ln_result}")

#  

exponential_result = math.exp(2) #    2

print(f"   2 = {exponential_result}")

```

          Python.

2.  `collections`

 `collections`  Python    ,         .     ,    :

`namedtuple`:      ,   , - .          .

`deque`:   (double-ended queue)           .  , ,    ,     .

`Counter`:               .          .

`defaultdict`:    ,         .   ,            .

      `collections`             .     `namedtuple`:

```python

from collections import namedtuple

#    "Person"

Person = namedtuple('Person', ['name', 'age', 'city'])

#    

person1 = Person(name='Alice', age=30, city='New York')

person2 = Person(name='Bob', age=25, city='San Francisco')

#     

print(person1.name) # : Alice

print(person2.city) # : San Francisco

```

  ,    `namedtuple`    .  ,     `collections`           .

        .      `timeit`,      .         `deque`   `collections`     :

```python

import timeit

from collections import deque

#   

big_list = list(range(1000000))

#         

def list_insert():

big_list.insert(0, 999)

#          

def deque_appendleft():

dq = deque(big_list)

dq.appendleft(999)

#     

list_time = timeit.timeit(list_insert, number=1000)

print(f"     {list_time:.6f} ")

#      

deque_time = timeit.timeit(deque_appendleft, number=1000)

print(f"      {deque_time:.6f} ")

```

               1000    .  ,    (`deque`)     ,             .

      ,    ,      `deque`    ,    . `deque`    ,           .

                 .



3.  `itertools`

 `itertools`  Python   ,      .              .         :

`itertools.count(start, step)`:     ,   ,   `start`    `step`   .

`itertools.cycle(iterable)`:   ,      `iterable`.

`itertools.repeat(elem, times)`:  ,    `elem` `times` .

`itertools.chain(iterable1, iterable2, )`:        .

`itertools.islice(iterable, start, stop, step)`:    ,   `start`    `stop`   `step`.

`itertools.filterfalse(predicate, iterable)`:    ,    `predicate`  `False`.

`itertools.groupby(iterable, key)`:         `key`.

`itertools.product(iterable1, iterable2, )`:      .

     `itertools`      . ,      ,      ( )  .     `itertools`   :

```python

import timeit

import itertools

#    

list1 = list(range(100000))

list2 = list(range(50000, 150000))

#         

def find_intersection_with_loop():

intersection = []

for item in list1:

if item in list2:

intersection.append(item)

#         itertools

def find_intersection_with_itertools():

intersection = list(itertools.filterfalse(lambda x: xnot in list2, list1))

#        

loop_time = timeit.timeit(find_intersection_with_loop, number=100)

print(f"     {loop_time:.6f} ")

#        itertools

itertools_time = timeit.timeit(find_intersection_with_itertools, number=100)

print(f"   itertools  {itertools_time:.6f} ")

```

                 `itertools`.     `itertools.filterfalse`,   ,    `list1`,    `list2`.      100    .

 ,      `itertools`   ,     ,          .



4.  `functools`

 `functools`  Python        .         `lru_cache`,     .      ,        .

   `lru_cache`   ,   :

```python

import functools

#    lru_cache   

@functools.lru_cache(maxsize=None)

def factorial(n):

if n == 0:

return 1

else:

return n factorial(n  1)

#     

result1 = factorial(5) #  ,   

result2 = factorial(5) #  ,    ,   

print(result1) # : 120

print(result2) # : 120

```

     `@functools.lru_cache(maxsize=None)`    `factorial`.  ,         , ,       .      ,     .              ,     .

   :

1.  :        .     ,        .

2.  :    ,           .   ,          .

3.  :    `lru_cache`       ,        .

  ,     (   `maxsize=None`)     ,             .     ,     ,   ,     .

`lru_cache`     ,         ,  ,      .



5.  `subprocess`

 `subprocess`  Python              Python-.            .         `subprocess`:

1.   :          Python,    ,      .

2.   :  `subprocess`       ,    ,     .

3.   :           .     .

4.   :            .  , ,     .

    `subprocess`         :

```python

import subprocess

#   "ls"     

result = subprocess.run(["ls", "-l"], capture_output=True, text=True, check=True)

#  

print(" :", result.returncode)

print(" :")

print(result.stdout)

```

    "ls -l" (      )    .     `subprocess`           Python.



6.  `multiprocessing`

 `multiprocessing`  Python       ,       .         Python,        .        `multiprocessing`:

 :  `multiprocessing`       .    ,    .

 :        ,     .

:  `multiprocessing`     ,     ,      .

 :   , ,    ,      .

     `multiprocessing`       :

```python

import multiprocessing

# ,     

def square(n):

return n n

if __name__ == "__main__":

#   

pool = multiprocessing.Pool(processes=4)

#   

numbers = [1, 2, 3, 4, 5, 6, 7, 8]

#    square   

results = pool.map(square, numbers)

#   

pool.close()

pool.join()

print(":", results)

```

       4      `square`     `numbers`.    ,      .

      `multiprocessing`:

1.   :      4    `multiprocessing.Pool(processes=4)`.       `square`   .

2.    :  `square`      .   ,       .

3.   :    `numbers`,   ,      .

4.   :  `pool.map(square, numbers)`      `square`     `numbers`.        ,    .       `results`.

5.   :            `pool.close()`        `pool.join()`.

6.  :      ,     `results`.          `numbers`.

  ,     `multiprocessing`    ,             .    ,         .  `multiprocessing`          ,          .



7.  `asyncio`

 `asyncio`  Python     ,      ,     .      - ,       ( )     .        `asyncio`:

 :  `asyncio`    ,      -,    .       .

: `asyncio`  ,    .     ,           ,     .

-:     `asyncio`  -,     . -    ,     ,    .

:       ,           .

 : `asyncio`      ,   -  ,      .

  Python     ,    .        ,      -,        .                .

      `async`   .   `await`           .           .

    ,      .      ,      -,       .               ,        .

   `asyncio`    ,           -.      :

```python

import asyncio

#   ()

async def hello():

print("Hello")

await asyncio.sleep(1) #    1 

print("World")

#    -

loop = asyncio.get_event_loop()

loop.run_until_complete(hello())

loop.close()

```

       `hello`,   "Hello",     1    "World".   -    .

 `asyncio`     ,        ,     ,      ,     .



8.  `threading`

 `threading`  Python     ,            .      ,   ,        .      ,     ,    .

          ,      ,        .        ,    .  ,          .           ,        .

   `threading`:

```python

import threading

# ,     

def print_numbers():

for i in range(1, 6):

print(f"Number: {i}")

#     

thread = threading.Thread(target=print_numbers)

thread.start()

#   

thread.join()

print("  ")

```

      ,    `print_numbers`.   ,              `join()`.  ,              .



9.  `random`

 `random`  Python       ,         .        ,               .

   `random`         ,     .     ,     .

           ,     .  ,             .

   `random`:

```python

import random

#      

random_number = random.randint(1, 100)

print(f" : {random_number}")

#     

fruits = ["", "", "", ""]

random_fruit = random.choice(fruits)

print(f" : {random_fruit}")

```

      `random`         1  100       .         ,  ,     ,        .



10.  `time`

 `time`  Python        ,       .           ,       .

     `time`  `time.time()`,          (   1  1970 ).             ,       .

     ,  `time`  `timeit`,            .        ,         .

   `time`     :

```python

import time

#    

start_time = time.time()

for _ in range(1000000):

#  - 

pass

end_time = time.time()

#   

duration = end_time  start_time

print(f" : {duration} ")

```

     `time.time()`     ,    - .        ,         .  `time`            .



11.  `cProfile`

 `cProfile`  Python      ,    ,           .        ,      ,  ,       .

`cProfile`  ,       ,    .        ,  ,      .     " " ,    .

   `cProfile`:

```python

import cProfile

# ,   

def some_function():

total = 0

for i in range(1000000):

total += i

return total

#  

cProfile.run("some_function()")

```

      `some_function`,     .    `cProfile.run()`     .     , ,           .

 `cProfile`  Python       .      ,    ,         .    ,     ,        .

   `cProfile`     ,     ,    ,     .     ,    ,   .  ,        ,     ,      .

  `cProfile`    ,     `some_function`.              .     ,       .  ,  `cProfile`      ,    " " .



12.  `profile`

 `timeit`  Python            .       ,     ,      .    `cProfile`, `timeit`            .

  `timeit`  `timeit.timeit()`,            .        ,       .

   `timeit`:

```python

import timeit

# ,   

def some_function():

total = 0

for i in range(1000000):

total += i

return total

#    

execution_time = timeit.timeit("some_function()", globals=globals(), number=10)

print(f"  : {execution_time / 10} ")

```

      `some_function`,    .    `timeit.timeit()`     10      .       .

`timeit`        ,       .     ,       .



13.  `dis`

 `dis`       - Python.        ,          .     :

```python

import dis

def example_function(x, y):

if x < y:

result = x + y

else:

result = x  y

return result

dis.dis(example_function)

```

      `example_function`,     .     `dis`   -  .    ,   Python     .    ,      , ,    ,     .

   `dis.dis(example_function)`,  `dis`  -  `example_function`      ,      - .

     :

1.   ( -     -).

2.   (  ).

3.   (  ).

   ,         .      :

```

2 0 LOAD_FAST 0 (x)

2 LOAD_FAST 1 (y)

4 COMPARE_OP 0 (<)

6 POP_JUMP_IF_FALSE 14

8 LOAD_FAST 0 (x)

10 LOAD_FAST 1 (y)

12 BINARY_ADD

14 STORE_FAST 2 (result)

16 JUMP_FORWARD 4 (to 22)

>> 18 LOAD_FAST 0 (x)

20 LOAD_FAST 1 (y)

>> 22 BINARY_SUBTRACT

24 STORE_FAST 2 (result)

26 LOAD_FAST 2 (result)

28 RETURN_VALUE

```

  ,      `example_function`    .      ,            ,   .

 `dis`        -,        ,       Python-.



14.  `gc` ( )

 `gc` ( )      Python,        .       ,      ,        .

   Python  ,          .   `gc`         ,       .

   `gc`:

```python

import gc

#    (   )

gc.enable()

#   

#    

gc.collect()

#    

print("  :")

print(gc.get_stats())

```

      `gc`,      `gc.enable()`,  - ,         `gc.collect()`.         `gc.get_stats()`.

       `gc`     :

```

  :

[{'collections': 3, 'collected': 0, 'uncollectable': 0}, {'collections': 0, 'collected': 0, 'uncollectable': 0}, {'collections': 0, 'collected': 0, 'uncollectable': 0}]

```

      .   ,   3  ,      ,        .

,              .  `gc`            ,         .

 `gc`             .    ,                   .



15.  `sys`

 `sys`     Python,         Python.      ,          .

   ,    ,        .     ,      ,     .        ,  Python     .  `sys`      :

```python

import sys

#    

stack_size = sys.getrecursionlimit()

#    

heap_size = sys.maxsize

print(f"  : {stack_size}")

print(f"  : {heap_size}")

```

     `sys.getrecursionlimit()`      (  ),  `sys.maxsize`     .

   ,    `sys`,    :

```

  : 3000

  : 9223372036854775807

```

     (  )               Python,   .

    Python      ,     ,         `RecursionError`.        `sys.getrecursionlimit()`   `sys`.

  `sys.getrecursionlimit()`  3000,  ,     Python        3000  .         `sys.setrecursionlimit()`    ,       . :

```python

import sys

#    

sys.setrecursionlimit(5000)

```

       5000  .   ,           ,         .

 ,  `sys.maxsize`     ,  ,  Python     .      ,    (   3000)      .     ,         (RecursionError).

 `sys`       ,      Python,   ,     .           Python-,         .

             .         ,      ,      .












2.2.  

           .    " " , ,        ,      .

        `cProfile`  `line_profiler`.

 1:  

      ,    `line_profiler`.       :

```

pip install line_profiler

```

`cProfile`     Python,     .

 2:    

 ,    . ,   ,   :

```python

def my_function():

result = 0

for i in range(1, 10001):

result += i

return result

```

 3:    `cProfile`

   `cProfile`        .      :

```python

import cProfile

if __name__ == "__main__":

cProfile.run('my_function()')

```

  . `cProfile.run()`      ,        .

 4:    `line_profiler`

`line_profiler`    .      :

```python

from line_profiler import LineProfiler

lp = LineProfiler()

@lp.profile

def my_function():

result = 0

for i in range(1, 10001):

result += i

return result

if __name__ == "__main__":

my_function()

lp.print_stats()

```

  . `@lp.profile`  ,  `line_profiler`    .   ,  `lp.print_stats()`         .

 5:  

  ,   ,    ,        .            .

 `cProfile`  `line_profiler`,       ,        .     :

1. Pyflame: Pyflame     Python,            .            CPU.

2. cProfile ( ):    `cProfile`      . , `python -m cProfile my_script.py`.

3. Py-Spy: Py-Spy    Python,          ,      .

4. Yappi: Yappi     Python,        .    CPU  ,     -   .

5. cachegrind/Callgrind:      C/C++,        Python   ,   `pyprof2calltree`.

6. memory_profiler:         ,        .

7. SnakeViz: SnakeViz       .         ,    .

  ,       .                .        ,             Python-.









2.3.       

          .

          .

  cProfile      SnakeViz:

```python

import cProfile

import snakeviz

def my_function():

result = 0

for i in range(1, 10001):

result += i

return result

if __name__ == "__main__":

cProfile.run('my_function()', filename='my_profile.prof')

snakeviz.view('my_profile.prof')

```

     `cProfile`    `my_function()`.     `'my_profile.prof'`.    `snakeviz`   .  `snakeviz.view('my_profile.prof')`   -      .

  line_profiler      SnakeViz:

```python

from line_profiler import LineProfiler

import snakeviz

lp = LineProfiler()

@lp.profile

def my_function():

result = 0

for i in range(1, 10001):

result += i

return result

if __name__ == "__main__":

my_function()

lp.print_stats()

lp.dump_stats('my_profile.lprof')

snakeviz.view('my_profile.lprof')

```

     `line_profiler`     `my_function()`.     `'my_profile.lprof'`.     `snakeviz`   ,  `snakeviz.view('my_profile.lprof')`.        .

  memory_profiler      SnakeViz:

```python

from memory_profiler import profile

import snakeviz

@profile

def my_function():

big_list = [i for i in range(1000000)]

return sum(big_list)

if __name__ == "__main__":

my_function()

snakeviz.view('my_function.mprof')

```

     `memory_profiler`      `my_function()`.     `'my_function.mprof'`.     `snakeviz`   ,  `snakeviz.view('my_function.mprof')`.      ,   .

 ,   SnakeViz     ,     ,         Python-.






 3:    



3.1.  O   

         .        " O" (Big O)   ,         .

 O (Big O)    ,      .    ,          .  ,  Big O       ,  ,          .

       Big O:

O(1)   .         .

O(log n)   .        .

O(n)   .      .

O(n log n)  - .

O(n^2)   .

O(2^n)   .

          ,       .                Big O,   ,     .

        Big O,   ,   .



 1:          O(n)   Big O.

,      ,         .                 ,    .   ,        ,          ,   .

,       n ,      x.          x.    ,           ,          .

      ,  ,          n  ,    .  ,  ,    ,     , .., O(n).

              O(n)   Big O.  ,      ,      .

    ,           O(n):

```python

def search_unsorted_list(lst, target):

for item in lst:

if item == target:

return True #  

return False #   

#   

my_list = [4, 2, 9, 7, 1, 5, 8, 3]

#    

target_element = 5

result = search_unsorted_list(my_list, target_element)

if result:

print(f" {target_element}   .")

else:

print(f" {target_element}    .")

```

  ,  `search_unsorted_list`    `lst`    `target`.            .   ,   `True`,  `False`.

     O(n),  ,   ,      .   ,  `my_list`  8 ,     ,     ,    8 .

  ,  ,    ,       .  :

,   `target_element`  5,      `my_list`.   ,   :

```

 5   .

```

      ,   :

```

 5    .

```

,        O(n)      .   ,      ,      , ,         ,   .



 2:  

        ,       .     - ,   ""   ,     .      ,    ,   ,          -    .

     :

1.           ,       (,     ).

2.      ,             .  ,     ""      .

3.         ,      ,      .

               ,     . , -   ,      ,          ,       .

      ,     ,       ,    . ,   ,       .          .

,      ,    ,       .        ,       ,         .

   Python  ,       :

```python

def is_sorted(arr):

n = len(arr)

for i in range(n  1):

for j in range(0, n  i  1):

if arr[j] > arr[j + 1]:

return False

return True

```

    `True`,     ,  `False`,  .     ,       . :

```python

my_list = [1, 2, 3, 4, 5]

if is_sorted(my_list):

print(" .")

else:

print("  .")

```

  ,  `my_list`   ,    " ."

              .   ,    .     ,              .

,  ,    ,    ,      ,       ,     -       .



 3:  

           .     O(log n),  n     .  ,          ,   ,    .

     :

1.     .

2.     ,  .   ,  .

3.       ,              .

4.       ,              .

5.   ,      ,           .

   Python   :

```python

def binary_search(arr, target):

left, right = 0, len(arr)  1

while left <= right:

mid = (left + right) // 2

if arr[mid] == target:

return mid #  ,   

elif arr[mid] < target:

left = mid + 1

else:

right = mid  1

return -1 #   

```

      :

,       ,     ,      .   ,      ,    .  ,   "", ,            ,   ,      .  ,  O(log n) ,           .

   ,  O(log n) ,      ,          .            ,        .

     ( O(n)),       ,         .    ,                 .

,             ,      ,      .         ,       .



 4:   

         ,           .       ,         .       ,       ,        ,     .

         :

1.   ,     .

2.              .           .

3.     ,           .

4.         ,      ,     .

5.  ,    ,          .

       :

,        ,      ,     .    , ,      ,    ,    .      ,         ,      .              .

   Python,     :

```python

def merge_sorted_lists(list1, list2):

merged_list = []

i = 0

j = 0

while i < len(list1) and j < len(list2):

if list1[i] < list2[j]:

merged_list.append(list1[i])

i += 1

else:

merged_list.append(list2[j])

j += 1

merged_list.extend(list1[i:])

merged_list.extend(list2[j:])

return merged_list

#  

list1 = [1, 3, 5, 7]

list2 = [2, 4, 6, 8]

result = merge_sorted_lists(list1, list2)

print(result)

```

        `list1`  `list2`    `result`.           `merged_list`.     `i`  `j`   .        ,          `merged_list`.

   ,    `list1`  `list2`.            ,     .



 5:  

        .   n (  n!)        1  n.         O(n),    n . ,    ,       ,    .

   Python       :

```python

def factorial_iterative(n):

result = 1

for i in range(1, n + 1):

result = i

return result

#  

n = 5

fact = factorial_iterative(n)

print(f"  {n}  {fact}")

```

      `result`  1         1  `n`.      O(n),       .

         ,       n.             n,                .

           ,         .

 :               .    ,           n   n    (n-1),    (n-2),   ,      ( n  1).

      ,           ,    .                 . ,     , ,      "  ",        .

        ,       .         ,          .          ,         ,     .

 :     ,         .    ,     1         1  n.            ,                 .

          ,         .       ,             ,     .

,    ,      ,  ,  ,       .           ,         .

          ,           ,   .  ,         ,      ,       .

 ,      n,   ,             .         n   ,         ,     .

      :   ,    .

 1:      .

```python

def factorial_recursive(n):

if n == 0:

return 1

else:

return n factorial_recursive(n  1)

#  

n = 5

fact = factorial_recursive(n)

print(f"  {n} ( )  {fact}")

```

         n.  `factorial_recursive`       n     (n = 0),   1.

 2:      .

```python

def factorial_iterative(n):

result = 1

for i in range(1, n + 1):

result = i

return result

#  

n = 5

fact = factorial_iterative(n)

print(f"  {n} ( )  {fact}")

```

              n.    1         1  n,     `result`.          ,            .

      ,           n,          .



 6:   

   n        ,       ,  ,   . ,  ,             n.

     O(n!),  n   .   ,          n. ,  n = 10   3 628 800  ,        .   n  ,      ,        .

,          ,          .       ,     ,       .

 ,   ,       ,        .

              . ,            ,             .

 ,        , ,       .   ,       . ,         ,        ,     .   ,           .

    Python,    itertools          :

```python

import itertools

def find_optimal_task_order(tasks, task_times):

min_time = float('inf')

optimal_order = []

for perm in itertools.permutations(tasks):

total_time = 0

for task in perm:

total_time += task_times[task]

if total_time < min_time:

min_time = total_time

optimal_order = list(perm)

return optimal_order

#  

tasks = [0, 1, 2, 3] #   

task_times = {0: 10, 1: 5, 2: 8, 3: 3} #    

optimal_order = find_optimal_task_order(tasks, task_times)

print(f"   : {optimal_order}")

```

                 .         .       ,        ,     .

 ,                       .

  Big O                    .         .


3.2.    

                 .



3.2.1.    

        ,          .            .

    ,  , ,   .        .   ,        ,      .

           . ,  `time`  Python   `time()`,       .            .

     .              .

        ,         .          ,     .

        Python:

```python

import time

start_time = time.time()




  .


   .

   ,     (https://www.litres.ru/chitat-onlayn/?art=69984919)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


