форкнуто от main/python-labs
Родитель
913bdd9254
Сommit
54bdfb684f
@ -0,0 +1,181 @@
|
||||
# Отчет по теме 2
|
||||
|
||||
Васильев Илья А-03-23
|
||||
|
||||
## 1 Запуск
|
||||
|
||||
## 2 Изучение простых объектов
|
||||
|
||||
```py
|
||||
f1=16; f2=3
|
||||
f1,f2
|
||||
(16, 3)
|
||||
f1;f2
|
||||
16
|
||||
3
|
||||
```
|
||||
```py
|
||||
dir()
|
||||
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'f1', 'f2']
|
||||
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']
|
||||
```
|
||||
|
||||
```py
|
||||
del f1,f2
|
||||
dir()
|
||||
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']
|
||||
```
|
||||
|
||||
## 3 Изучение правил наименования объектов
|
||||
|
||||
```py
|
||||
gg1=1.6
|
||||
hh1='Строка'
|
||||
73sr=3
|
||||
SyntaxError: invalid syntax
|
||||
and=7
|
||||
SyntaxError: invalid syntax
|
||||
```
|
||||
|
||||
## 4 Ключевые слова
|
||||
|
||||
```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']
|
||||
keylist = keyword.kwlist
|
||||
```
|
||||
|
||||
## Вывод списка встроенных идентификаторов
|
||||
|
||||
```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']
|
||||
```
|
||||
|
||||
Изучены назначения функций и применены некоторые из них
|
||||
|
||||
```py
|
||||
abs(-3)
|
||||
3
|
||||
max(3, 2, 9)
|
||||
9
|
||||
round(3.6)
|
||||
4
|
||||
a='bibibibi'
|
||||
len(a)
|
||||
8
|
||||
```
|
||||
|
||||
## 6 Изучение зависимости от заглавной буквы
|
||||
|
||||
```py
|
||||
Gg1=45
|
||||
gg1
|
||||
1.6
|
||||
Gg1
|
||||
45
|
||||
```
|
||||
|
||||
## 7 Изучение простых базовых объектов
|
||||
|
||||
## 7.1 Логический тип
|
||||
|
||||
```py
|
||||
bb1=True; bb2=False
|
||||
bb1;bb2
|
||||
True
|
||||
False
|
||||
type(bb1)
|
||||
<class 'bool'>
|
||||
```
|
||||
|
||||
## 7.2 Другие простые типы
|
||||
|
||||
```py
|
||||
ii1=-1234567890
|
||||
type(ii1)
|
||||
<class 'int'>
|
||||
ff1=-8.9876e-12
|
||||
type(ff1)
|
||||
<class 'float'>
|
||||
dv1=0b1101010
|
||||
type(dv1)
|
||||
<class 'int'>
|
||||
vsm1=0o52765
|
||||
type(vsm1)
|
||||
<class 'int'>
|
||||
shest1=0x7109af6
|
||||
type(shest1)
|
||||
<class 'int'>
|
||||
cc1=2-3j
|
||||
type(cc1)
|
||||
<class 'complex'>
|
||||
a=3.67; b=-0.45
|
||||
cc2=complex(a,b)
|
||||
type(cc2)
|
||||
<class 'complex'>
|
||||
```
|
||||
|
||||
## 7.3 Строка символов
|
||||
|
||||
```py
|
||||
ss1a="Это - \" строка символов \", \n \t выводимая на двух строках"
|
||||
print(ss1a)
|
||||
Это - " строка символов ",
|
||||
выводимая на двух строках
|
||||
```
|
||||
|
||||
```py
|
||||
ss1b= 'Меня зовут: \n Илья'
|
||||
print(ss1b)
|
||||
Меня зовут:
|
||||
Илья
|
||||
```
|
||||
```py
|
||||
mnogo="""Нетрудно заметить , что в результате операции
|
||||
над числами разных типов получается число,
|
||||
имеющее более сложный тип из тех, которые участвуют в операции."""
|
||||
|
||||
print(mnogo)
|
||||
Нетрудно заметить , что в результате операции
|
||||
над числами разных типов получается число,
|
||||
имеющее более сложный тип из тех, которые участвуют в операции.
|
||||
```
|
||||
|
||||
```py
|
||||
ss1[0]
|
||||
'Э'
|
||||
ss1[8]
|
||||
'р'
|
||||
ss1[-2]
|
||||
'о'
|
||||
ss1[6:9]
|
||||
'стр'
|
||||
ss1[13:]
|
||||
'символов'
|
||||
ss1[:13]
|
||||
'Это - строка '
|
||||
ss1[5:-8]
|
||||
' строка '
|
||||
ss1[3:17:2]
|
||||
' тоасм'
|
||||
ss1[17:3:-2]
|
||||
'омсаот '
|
||||
ss1[-4:3:-2]
|
||||
'омсаот '
|
||||
```
|
||||
|
||||
```py
|
||||
ss1[4]='='
|
||||
```
|
||||
|
||||
```py
|
||||
ss1=ss1[:4]+'='+ss1[5:]
|
||||
print(ss1)
|
||||
Это = строка символов
|
||||
```
|
||||
|
||||
Работа со строкой
|
Загрузка…
Ссылка в новой задаче