diff --git a/TEMA2/1.png b/TEMA2/1.png new file mode 100644 index 0000000..7b1255a Binary files /dev/null and b/TEMA2/1.png differ diff --git a/TEMA2/2.png b/TEMA2/2.png new file mode 100644 index 0000000..b6bc931 Binary files /dev/null and b/TEMA2/2.png differ diff --git a/TEMA2/abs.png b/TEMA2/abs.png new file mode 100644 index 0000000..d0166ee Binary files /dev/null and b/TEMA2/abs.png differ diff --git a/TEMA2/len.png b/TEMA2/len.png new file mode 100644 index 0000000..77f2a44 Binary files /dev/null and b/TEMA2/len.png differ diff --git a/TEMA2/report.md b/TEMA2/report.md new file mode 100644 index 0000000..5ddd47b --- /dev/null +++ b/TEMA2/report.md @@ -0,0 +1,299 @@ +# Отчет по теме 2 + +Ефремов Станислав, А-02-23 + +## 1. Запуск. + +### 1.1 Запуск оболочки IDLE и установка рабочего каталога. + +```py +import os +os.chdir('C:\Program Files (x86)\учёха 3 курс\pythonsky\python-labs\TEMA2') +``` + +![](1.png) + +## 2. Изучение простых объектов. + +### 2.1 Операции присваивания + +```py +f1=16; f2=3 +f1,f2 +(16, 3) +f1;f2 +16 +3 +``` +### 2.2 Функционал команд dir(), type() и del: + +Был получен список атрибутов объекта f1: + +```py +dir(f1) +['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_count', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'is_integer', 'numerator', 'real', 'to_bytes'] +``` + +Также была определена классовая принадлежность объекта f2: + +```py +type(f2) + +``` + +Команда del отвечает за удаление объекта или его части из ОП. + +```py +del f1, f2 + +f1, f2 +Traceback (most recent call last): + File "", line 1, in + f1, f2 +NameError: name 'f1' is not defined +``` + +## 3-4. Правила именования и сохранение списка под именем: + +Были введены некоторые предложенные команды, две из которых не соответствовали правилам именования: + +![](2.png) + +```py +import keyword +keyword.kwlist +['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] +``` +В данном случае полученному списку было присвоено следующее имя: + +```py +ara = keyword.kwlist +ara +['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] +``` + +## 5. Встроенные идентификаторы. + +### 5.1 Вывод списка встроенных идентификаторов: + +```py +import builtins +dir(builtins) +['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BaseExceptionGroup', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EncodingWarning', 'EnvironmentError', 'Exception', 'ExceptionGroup', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'PythonFinalizationError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', '_IncompleteInputError', '__build_class__', '__debug__', '__doc__', '__import__', '__loader__', '__name__', '__package__', '__spec__', 'abs', 'aiter', 'all', 'anext', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip'] +``` +### 5.2 Изучение назначения функций: + +#### 5.2.1 Функция ABS: + +![](abs.png) + +#### 5.2.2 Функция len: + +![](len.png) + +#### 5.2.3 Функция max + +```py +help(max) +Help on built-in function max in module builtins: + +max(...) + max(iterable, *[, default=obj, key=func]) -> value + ....... + With two or more positional arguments, return the largest argument. + +max(numbers) +3 +``` + +#### 5.2.4 Функция min + +```py +help(min) +Help on built-in function min in module builtins: + +min(...) + min(iterable, *[, default=obj, key=func]) -> value + ............ + With two or more positional arguments, return the smallest argument. + +min(numbers) +1 +``` + + +#### 5.2.5 Функция pow + +```py +help(pow) +Help on built-in function pow in module builtins: + +pow(base, exp, mod=None) + ........... +invoked using the three argument form. + +pow(3, 2) +9 +``` + +#### 5.2.6 Функция round + +```py +help(round) +Help on built-in function round in module builtins: + +round(number, ndigits=None) + Round a number to a given precision in decimal digits. + + The return value is an integer if ndigits is omitted or None. Otherwise + the return value has the same type as the number. ndigits may be negative. + +round(1.5) +2 +``` + +#### 5.2.7 Функция sorted + +```py +help (sorted) +Help on built-in function sorted in module builtins: + +sorted(iterable, /, *, key=None, reverse=False) + Return a new list containing all items from the iterable in ascending order. + + A custom key function can be supplied to customize the sort order, and the + reverse flag can be set to request the result in descending order. + +num = [3, 1, 2] +sorted(num) +[1, 2, 3] +``` + + + +#### 5.2.8 Функция sum + +```py +help(sum) +Help on built-in function sum in module builtins: + +sum(iterable, /, start=0) + Return the sum of a 'start' value (default: 0) plus an iterable of numbers + + When the iterable is empty, return the start value. + This function is intended specifically for use with numeric values and may + reject non-numeric types. + +sum(num) +6 +``` + +#### 5.2.9 Функция zip + +```py +help(zip) +Help on class zip in module builtins: + +class zip(object) + | zip(*iterables, strict=False) + | + | The zip object yields n-length tuples, where n is the number of iterables + | passed as positional arguments to zip(). The i-th element in every tuple + | comes from the i-th iterable argument to zip(). This continues until the +........................................... + +num +[3, 1, 2] +numbers +[1, 2, 3] +j = zip(num, numbers) +j + +zip_list = list(j) +zip_list +[(3, 1), (1, 2), (2, 3)] +``` + +## 6-7. Типы объектов. + +### 6 Проверка влияния больших и маленьких букв в имени переменных: + +```py +Gg1=45 +gg1 +1.6 +Gg1 +45 +``` +### 7 Изучение базовых типов объектов: + +int — целые числа (положительные, отрицательные или нуль). +float — числа с плавающей точкой (дробные числа). +complex — комплексные числа (имеют действительную и мнимую части). +str — строковый тип данных для хранения текстовой информации. Строка может содержать буквы, цифры, пробелы, символы. +bool в Python — это логический тип, принимать только два значения: True и False. + + +#### 7.1 Логический тип: + +```py +bb1 = True +bb2 = False +bb1;bb2 +True +False +type(bb1) + +``` + +#### 7.2 Иные простые типы: + +```py +ii1=-1234567890 +type(ii1) + + +ff1=-8.9876e-12 +type(ff1) + + + +dv1=0b1101010 + +type(dv1) + + +``` + +Как можем заметить - двоичное число 0b1101010 в Python сохраняется в объекте класса int. + +```py +vsm1=0o52765 +type(vsm1) + +``` + +```py +shest1=0x7109af6 +type(shest1) + +cc1=2-3j +type(cc1) + +``` + +Ниже представлен иной способ создания комплексного числа: + +```py +a=3.67; b=-0.45 +cc2=complex(a,b) +type(cc2) + +``` + +#### 7.3 Строка символом: + + + + +