GoloshchapovDY 2 месяцев назад
Родитель 713865f3f3
Сommit e2633362b4

@ -1,219 +1,426 @@
#Протокол лабораторной работы 2 Голощапов Дмитрий Евгеньевич # Протокол лабораторной работы 2 Голощапов Дмитрий Евгеньевич
Python 3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)] on win32 Python 3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information. Type "help", "copyright", "credits" or "license()" for more information.
import os import os
os.chdir('C:\\Users\\Дмитрий\\OneDrive\\Рабочий стол\\Goloshchapov\\python-labs\\TEMA2') os.chdir('C:\\Users\\Дмитрий\\OneDrive\\Рабочий стол\\Goloshchapov\\python-labs\\TEMA2')
f1 = 16; f2 = 3 f1 = 16; f2 = 3
f1, f2 f1, f2
(16, 3) (16, 3)
f1; f2 f1; f2
16 16
3 3
dir() dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'f1', 'f2', 'os'] ['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'f1', 'f2', 'os']
dir (f1) dir (f1)
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__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', 'numerator', 'real', 'to_bytes'] ['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__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', 'numerator', 'real', 'to_bytes']
type(f2) type(f2)
<class 'int'> <class 'int'>
del f1, f2 del f1, f2
dir() dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'os'] ['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'os']
gg1 = 1.6 gg1 = 1.6
gg1 gg1
1.6 1.6
hh1 = 'example' hh1 = 'example'
hh1 hh1
'example' 'example'
73sr = 3 73sr = 3
SyntaxError: invalid decimal literal SyntaxError: invalid decimal literal
and = 7 and = 7
SyntaxError: invalid syntax SyntaxError: invalid syntax
import keyword import keyword
keyword.kwlist 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'] ['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']
kwd = keyword.kwlist kwd = keyword.kwlist
kwd kwd
['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'] ['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']
type(kwd) type(kwd)
<class 'list'> <class 'list'>
import builtins import builtins
dir(builtins) dir(builtins)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EncodingWarning', 'EnvironmentError', 'Exception', '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', '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', '_', '__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']
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EncodingWarning', 'EnvironmentError', 'Exception', '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', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'S
ystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', '__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']
abs(-5) abs(-5)
5 5
len([1, 2, 3]) len([1, 2, 3])
3 3
max(14, 8) max(14, 8)
14 14
min (15, 0) min (15, 0)
0 0
pow (5, 2) pow (5, 2)
25 25
round (3,124) round (3,124)
3 3
sum ([7, 3, 5]) sum ([7, 3, 5])
15 15
sorted ([3, 7, 9, 75, 0, -1]) sorted ([3, 7, 9, 75, 0, -1])
[-1, 0, 3, 7, 9, 75] [-1, 0, 3, 7, 9, 75]
list1 = [1, 2, 3] list1 = [1, 2, 3]
list2 = [4, 5, 6] list2 = [4, 5, 6]
zip (list1, list2) zip (list1, list2)
<zip object at 0x0000019F7EA6E700> <zip object at 0x0000019F7EA6E700>
list(zipped) list(zipped)
Traceback (most recent call last): Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module> File "<pyshell#34>", line 1, in <module>
list(zipped) list(zipped)
NameError: name 'zipped' is not defined NameError: name 'zipped' is not defined
Gg1 = 45 Gg1 = 45
gg1, Gg1 gg1, Gg1
(1.6, 45) (1.6, 45)
gg1 == Gg1 gg1 == Gg1
False False
bb1 = True bb1 = True
SyntaxError: unexpected indent SyntaxError: unexpected indent
KeyboardInterrupt KeyboardInterrupt
bb1 = True bb1 = True
bb2 = False bb2 = False
type(bb1) type(bb1)
<class 'bool'> <class 'bool'>
ii1=-1234567890 ii1=-1234567890
type(ii1) type(ii1)
<class 'int'> <class 'int'>
ff1 = 8.987e-12 ff1 = 8.987e-12
type(ff1) type(ff1)
<class 'float'> <class 'float'>
dv1 = 0b1100101 dv1 = 0b1100101
type(dv1) type(dv1)
<class 'int'> <class 'int'>
vsm1 = 0o52765 vsm1 = 0o52765
type(vsm1) type(vsm1)
<class 'int'> <class 'int'>
shest1 = 0x7109af6 shest1 = 0x7109af6
type(shest1) type(shest1)
<class 'int'> <class 'int'>
cc1 = 2 - 3j cc1 = 2 - 3j
type(cc1) type(cc1)
<class 'complex'> <class 'complex'>
a = 3.67 a = 3.67
b = 0.45 b = 0.45
cc2 = complex (a, b) cc2 = complex (a, b)
cc2 cc2
(3.67+0.45j) (3.67+0.45j)
type (cc2) type (cc2)
<class 'complex'> <class 'complex'>
ss1 = "Это - строка символов" ss1 = "Это - строка символов"
ss2 = 'Это - строка символов' ss2 = 'Это - строка символов'
ss1 == ss2 ss1 == ss2
True True
ss1a="Это - \" строка символов \", \n \t выводимая на двух строках" ss1a="Это - \" строка символов \", \n \t выводимая на двух строках"
print(ss1a) print(ss1a)
Это - " строка символов ", Это - " строка символов ",
выводимая на двух строках выводимая на двух строках
ss1b = 'Меня зовут: \n Голощапов Д.Е.' ss1b = 'Меня зовут: \n Голощапов Д.Е.'
print(ss1b) print(ss1b)
Меня зовут: Меня зовут:
Голощапов Д.Е. Голощапов Д.Е.
mnogo="""Нетрудно заметить , что в результате операции mnogo="""Нетрудно заметить , что в результате операции
над числами разных типов получается число, над числами разных типов получается число,
имеющее более сложный тип из тех, которые участвуют в операции.""" имеющее более сложный тип из тех, которые участвуют в операции."""
print(mnogo) print(mnogo)
Нетрудно заметить , что в результате операции Нетрудно заметить , что в результате операции
над числами разных типов получается число, над числами разных типов получается число,
имеющее более сложный тип из тех, которые участвуют в операции. имеющее более сложный тип из тех, которые участвуют в операции.
ss1[0] ss1[0]
'Э' 'Э'
ss1[8] ss1[8]
'р' 'р'
ss1[-2] ss1[-2]
'о' 'о'
ss1[6:9] ss1[6:9]
'стр' 'стр'
ss1[13:] ss1[13:]
'символов' 'символов'
ss1[:13] ss1[:13]
'Это - строка ' 'Это - строка '
ss1[5:-8] ss1[5:-8]
' строка ' ' строка '
ss1[3:17:2] ss1[3:17:2]
' тоасм' ' тоасм'
ss1[17:3:-2] ss1[17:3:-2]
'омсаот ' 'омсаот '
ss1[-4:3:-2] ss1[-4:3:-2]
'омсаот ' 'омсаот '
ss1[4]='=' ss1[4]='='
Traceback (most recent call last): Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module> File "<pyshell#78>", line 1, in <module>
ss1[4]='=' ss1[4]='='
TypeError: 'str' object does not support item assignment TypeError: 'str' object does not support item assignment
ss1=ss1[:4]+'='+ss1[5:] ss1=ss1[:4]+'='+ss1[5:]
ss1 ss1
'Это = строка символов' 'Это = строка символов'
ss1b[-1] ss1b[-1]
'.' '.'
ss1b_cut = ss1b [::-1] ss1b_cut = ss1b [::-1]
ss1b_cut ss1b_cut
'.Е.Д вопащолоГ \n :тувоз янеМ' '.Е.Д вопащолоГ \n :тувоз янеМ'
num10 = 26 num10 = 26
type(num10) type(num10)
<class 'int'> <class 'int'>
num16 = hex(num10) num16 = hex(num10)
num16 num16
'0x1a' '0x1a'
type(num16) type(num16)
<class 'str'> <class 'str'>
str1 = str(num10) + ' в десятичной - это ' + str(num16) + ' в шестнадцатеричной ' str1 = str(num10) + ' в десятичной - это ' + str(num16) + ' в шестнадцатеричной '
str1 str1
'26 в десятичной - это 0x1a в шестнадцатеричной ' '26 в десятичной - это 0x1a в шестнадцатеричной '
str1[5:16:3] str1[5:16:3]
'дячй' 'дячй'
spis1=[111,'Spisok',5-9j] spis1=[111,'Spisok',5-9j]
spis1 spis1
[111, 'Spisok', (5-9j)] [111, 'Spisok', (5-9j)]
stup=[0,0,1,1,1,1,1,1,1] stup=[0,0,1,1,1,1,1,1,1]
stup stup
[0, 0, 1, 1, 1, 1, 1, 1, 1] [0, 0, 1, 1, 1, 1, 1, 1, 1]
spis=[1,2,3,4, spis=[1,2,3,4,
5,6,7, 5,6,7,
8,9,10] 8,9,10]
spis spis
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
spis1 [-1] spis1 [-1]
(5-9j) (5-9j)
stup [-8 :: 2] stup [-8 :: 2]
[0, 1, 1, 1] [0, 1, 1, 1]
spis1[1]='Список' spis1[1]='Список'
spis1 spis1
[111, 'Список', (5-9j)] [111, 'Список', (5-9j)]
len(spis1) len(spis1)
3 3
help(spis1.append) help(spis1.append)
Help on built-in function append: Help on built-in function append:
append(object, /) method of builtins.list instance append(object, /) method of builtins.list instance
Append object to the end of the list. Append object to the end of the list.
spis1.append('New item') spis1.append('New item')
spis1 spis1
[111, 'Список', (5-9j), 'New item'] [111, 'Список', (5-9j), 'New item']
spis1+['New item'] spis1+['New item']
[111, 'Список', (5-9j), 'New item', 'New item'] [111, 'Список', (5-9j), 'New item', 'New item']
spis1 spis1
[111, 'Список', (5-9j), 'New item'] [111, 'Список', (5-9j), 'New item']
spis1 += ss1b spis1 += ss1b
spis1 spis1
[111, 'Список', (5-9j), 'New item', 'М', 'е', 'н', 'я', ' ', 'з', 'о', 'в', 'у', 'т', ':', ' ', '\n', ' ', 'Г', 'о', 'л', 'о', 'щ', 'а', 'п', 'о', 'в', ' ', 'Д', '.', 'Е', '.'] [111, 'Список', (5-9j), 'New item', 'М', 'е', 'н', 'я', ' ', 'з', 'о', 'в', 'у', 'т', ':', ' ', '\n', ' ', 'Г', 'о', 'л', 'о', 'щ', 'а', 'п', 'о', 'в', ' ', 'Д', '.', 'Е', '.']
spis1 spis1
[111, 'Список', (5-9j), 'New item', 'М', 'е', 'н', 'я', ' ', 'з', 'о', 'в', 'у', 'т', ':', ' ', '\n', ' ', 'Г', 'о', 'л', 'о', 'щ', 'а', 'п', 'о', 'в', ' ', 'Д', '.', 'Е', '.'] [111, 'Список', (5-9j), 'New item', 'М', 'е', 'н', 'я', ' ', 'з', 'о', 'в', 'у', 'т', ':', ' ', '\n', ' ', 'Г', 'о', 'л', 'о', 'щ', 'а', 'п', 'о', 'в', ' ', 'Д', '.', 'Е', '.']
spis1 = [111, 'Список', (5-9j), 'New item'] spis1 = [111, 'Список', (5-9j), 'New item']
spis1.append(ss1b) spis1.append(ss1b)
spis1 spis1
[111, 'Список', (5-9j), 'New item', 'Меня зовут: \n Голощапов Д.Е.'] [111, 'Список', (5-9j), 'New item', 'Меня зовут: \n Голощапов Д.Е.']
spis1.pop(1) spis1.pop(1)
'Список' 'Список'
spis1 spis1
[111, (5-9j), 'New item', 'Меня зовут: \n Голощапов Д.Е.'] [111, (5-9j), 'New item', 'Меня зовут: \n Голощапов Д.Е.']
spis1.pop(7) spis1.pop(7)
Traceback (most recent call last): Traceback (most recent call last):
File "<pyshell#116>", line 1, in <module> File "<pyshell#116>", line 1, in <module>
spis1.pop(7) spis1.pop(7)
@ -225,11 +432,18 @@ insert(index, object, /) method of builtins.list instance
Insert object before index. Insert object before index.
spis1.insert(2, "hello") spis1.insert(2, "hello")
spis1 spis1
[111, (5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.'] [111, (5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.']
spis1.insert(8, "test") spis1.insert(8, "test")
spis1 spis1
[111, (5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test'] [111, (5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test']
help(spis1.remove) help(spis1.remove)
Help on built-in function remove: Help on built-in function remove:
@ -238,10 +452,15 @@ remove(value, /) method of builtins.list instance
Raises ValueError if the value is not present. Raises ValueError if the value is not present.
spis1.remove(111) spis1.remove(111)
spis1 spis1
[(5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test'] [(5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test']
spis1.remove('kitten') spis1.remove('kitten')
Traceback (most recent call last): Traceback (most recent call last):
File "<pyshell#125>", line 1, in <module> File "<pyshell#125>", line 1, in <module>
spis1.remove('kitten') spis1.remove('kitten')
@ -253,18 +472,25 @@ extend(iterable, /) method of builtins.list instance
Extend list by appending elements from the iterable. Extend list by appending elements from the iterable.
end1 = [123, "mew", (1,2)] end1 = [123, "mew", (1,2)]
spis1.extend(end1) spis1.extend(end1)
spis1 spis1
[(5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)] [(5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)]
help(spis1.clear) help(spis1.clear)
Help on built-in function clear: Help on built-in function clear:
clear() method of builtins.list instance clear() method of builtins.list instance
Remove all items from list. Remove all items from list.
end1.clear() end1.clear()
end1 end1
[] []
help(spis1.sort) help(spis1.sort)
Help on built-in function sort: Help on built-in function sort:
@ -279,20 +505,30 @@ sort(*, key=None, reverse=False) method of builtins.list instance
The reverse flag can be set to sort in descending order. The reverse flag can be set to sort in descending order.
end1 = [5, 6, 9.99999, 384, 0, -5] end1 = [5, 6, 9.99999, 384, 0, -5]
end1.sort(key = abs, reverse = True) end1.sort(key = abs, reverse = True)
end1 end1
[384, 9.99999, 6, 5, -5, 0] [384, 9.99999, 6, 5, -5, 0]
help(end1.copy) help(end1.copy)
Help on built-in function copy: Help on built-in function copy:
copy() method of builtins.list instance copy() method of builtins.list instance
Return a shallow copy of the list. Return a shallow copy of the list.
endcopy = end1.copy() endcopy = end1.copy()
endcopy endcopy
[384, 9.99999, 6, 5, -5, 0] [384, 9.99999, 6, 5, -5, 0]
help(endcopy.index) help(endcopy.index)
Help on built-in function index: Help on built-in function index:
index(value, start=0, stop=9223372036854775807, /) method of builtins.list instance index(value, start=0, stop=9223372036854775807, /) method of builtins.list instance
@ -300,9 +536,13 @@ index(value, start=0, stop=9223372036854775807, /) method of builtins.list insta
Raises ValueError if the value is not present. Raises ValueError if the value is not present.
endcopy.index(0) endcopy.index(0)
5 5
endopy.index("lalala") endopy.index("lalala")
Traceback (most recent call last): Traceback (most recent call last):
File "<pyshell#142>", line 1, in <module> File "<pyshell#142>", line 1, in <module>
endopy.index("lalala") endopy.index("lalala")
@ -313,94 +553,179 @@ Help on built-in function count:
count(value, /) method of builtins.list instance count(value, /) method of builtins.list instance
Return number of occurrences of value. Return number of occurrences of value.
endcopy.count(5) endcopy.count(5)
1 1
endcopy.count(666666) endcopy.count(666666)
0 0
spis2=[spis1,[4,5,6,7]] spis2=[spis1,[4,5,6,7]]
spis2 spis2
[[(5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)], [4, 5, 6, 7]] [[(5-9j), 'hello', 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)], [4, 5, 6, 7]]
spis2[0][1] spis2[0][1]
'hello' 'hello'
spis2[0][1]=78 spis2[0][1]=78
spis2 spis2
[[(5-9j), 78, 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)], [4, 5, 6, 7]] [[(5-9j), 78, 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)], [4, 5, 6, 7]]
spis1 spis1
[(5-9j), 78, 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)] [(5-9j), 78, 'New item', 'Меня зовут: \n Голощапов Д.Е.', 'test', 123, 'mew', (1, 2)]
kort1=(222,'Kortezh',77+8j) kort1=(222,'Kortezh',77+8j)
kort1= kort1+(1,2) kort1= kort1+(1,2)
kort1 kort1
(222, 'Kortezh', (77+8j), 1, 2) (222, 'Kortezh', (77+8j), 1, 2)
kort1= kort1+(ss1b,) kort1= kort1+(ss1b,)
kort1 kort1
(222, 'Kortezh', (77+8j), 1, 2, 'Меня зовут: \n Голощапов Д.Е.') (222, 'Kortezh', (77+8j), 1, 2, 'Меня зовут: \n Голощапов Д.Е.')
kort2=kort1[:2]+kort1[3:] kort2=kort1[:2]+kort1[3:]
kort2 kort2
(222, 'Kortezh', 1, 2, 'Меня зовут: \n Голощапов Д.Е.') (222, 'Kortezh', 1, 2, 'Меня зовут: \n Голощапов Д.Е.')
kort1.index(2) kort1.index(2)
4 4
kort1.count(222) kort1.count(222)
1 1
kort1[2]=90 kort1[2]=90
Traceback (most recent call last): Traceback (most recent call last):
File "<pyshell#161>", line 1, in <module> File "<pyshell#161>", line 1, in <module>
kort1[2]=90 kort1[2]=90
TypeError: 'tuple' object does not support item assignment TypeError: 'tuple' object does not support item assignment
kortstr = ("h", "lambda", "always", 54, [1,2,3], (6,7)) kortstr = ("h", "lambda", "always", 54, [1,2,3], (6,7))
kortstr kortstr
('h', 'lambda', 'always', 54, [1, 2, 3], (6, 7)) ('h', 'lambda', 'always', 54, [1, 2, 3], (6, 7))
type(kortstr[5]) type(kortstr[5])
<class 'tuple'> <class 'tuple'>
type(kortstr[4]) type(kortstr[4])
<class 'list'> <class 'list'>
dic1={'Saratov':145, 'Orel':56, 'Vologda':45} dic1={'Saratov':145, 'Orel':56, 'Vologda':45}
dic1 dic1
{'Saratov': 145, 'Orel': 56, 'Vologda': 45} {'Saratov': 145, 'Orel': 56, 'Vologda': 45}
dic1[1] dic1[1]
Traceback (most recent call last): Traceback (most recent call last):
File "<pyshell#168>", line 1, in <module> File "<pyshell#168>", line 1, in <module>
dic1[1] dic1[1]
KeyError: 1 KeyError: 1
dic1['Orel'] dic1['Orel']
56 56
dic1['Pskov']=78 dic1['Pskov']=78
dic1 dic1
{'Saratov': 145, 'Orel': 56, 'Vologda': 45, 'Pskov': 78} {'Saratov': 145, 'Orel': 56, 'Vologda': 45, 'Pskov': 78}
sorted(dic1.keys()) sorted(dic1.keys())
['Orel', 'Pskov', 'Saratov', 'Vologda'] ['Orel', 'Pskov', 'Saratov', 'Vologda']
sorted(dic1.values()) sorted(dic1.values())
[45, 56, 78, 145] [45, 56, 78, 145]
dic2={1:'mean',2:'standart deviation',3:'correlation'} dic2={1:'mean',2:'standart deviation',3:'correlation'}
dic3={'statistics':dic2,'POAS':['base','elementary','programming']} dic3={'statistics':dic2,'POAS':['base','elementary','programming']}
dic3['statistics'][2] dic3['statistics'][2]
'standart deviation' 'standart deviation'
dic4=dict([(1,['A','B','C']),(2,[4,5]),('Q','Prim'),('Stroka',ss1b)]) dic4=dict([(1,['A','B','C']),(2,[4,5]),('Q','Prim'),('Stroka',ss1b)])
dic4 dic4
{1: ['A', 'B', 'C'], 2: [4, 5], 'Q': 'Prim', 'Stroka': 'Меня зовут: \n Голощапов Д.Е.'} {1: ['A', 'B', 'C'], 2: [4, 5], 'Q': 'Prim', 'Stroka': 'Меня зовут: \n Голощапов Д.Е.'}
dic5=dict(zip(['A','B','C','Stroka'],[16,-3,9,ss1b])) dic5=dict(zip(['A','B','C','Stroka'],[16,-3,9,ss1b]))
dic5 dic5
{'A': 16, 'B': -3, 'C': 9, 'Stroka': 'Меня зовут: \n Голощапов Д.Е.'} {'A': 16, 'B': -3, 'C': 9, 'Stroka': 'Меня зовут: \n Голощапов Д.Е.'}
terms_tuple = ("mean", "median", "mode", "variance", "standard deviation", "correlation", "regression") terms_tuple = ("mean", "median", "mode", "variance", "standard deviation", "correlation", "regression")
count_list = ["one", "two", "three", "four", "five"] count_list = ["one", "two", "three", "four", "five"]
terms_dict = dict(zip(count_list, terms_tuple)) terms_dict = dict(zip(count_list, terms_tuple))
terms_dict terms_dict
{'one': 'mean', 'two': 'median', 'three': 'mode', 'four': 'variance', 'five': 'standard deviation'} {'one': 'mean', 'two': 'median', 'three': 'mode', 'four': 'variance', 'five': 'standard deviation'}
mnoz1={'двигатель','датчик','линия связи','датчик','микропроцессор','двигатель'} mnoz1={'двигатель','датчик','линия связи','датчик','микропроцессор','двигатель'}
mnoz1 mnoz1
{'микропроцессор', 'датчик', 'линия связи', 'двигатель'} {'микропроцессор', 'датчик', 'линия связи', 'двигатель'}
len(mnoz1) len(mnoz1)
4 4
'датчик' in mnoz1 'датчик' in mnoz1
True True
mnoz1.add('реле') mnoz1.add('реле')
mnoz1.remove('линия связи') mnoz1.remove('линия связи')
mnoz1 mnoz1
{'реле', 'датчик', 'микропроцессор', 'двигатель'} {'реле', 'датчик', 'микропроцессор', 'двигатель'}
mnoz2 = {'спичка', 15, False, 'gear'} mnoz2 = {'спичка', 15, False, 'gear'}
mnoz2 mnoz2
{False, 'спичка', 'gear', 15} {False, 'спичка', 'gear', 15}
len(mnoz2) len(mnoz2)
4 4
mnoz2.remove(15) mnoz2.remove(15)
mnoz2 mnoz2
{False, 'спичка', 'gear'} {False, 'спичка', 'gear'}
Загрузка…
Отмена
Сохранить