diff --git a/TEMA2/protocol.py b/TEMA2/protocol.py new file mode 100644 index 0000000..32a73d7 --- /dev/null +++ b/TEMA2/protocol.py @@ -0,0 +1,188 @@ +#Протокол по Теме 2 Соловьёва Е.Д. +f1=16; f2=3 +f1,f2 +(16, 3) +dir() +['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'f1', 'f2', 'os'] +type(f2) + +del f1,f2 +dir() +['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'os'] +f1=16; f2=3 +dir(f2) +['__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'] +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'] + +help(abs) +Help on built-in function abs in module builtins: + +abs(x, /) + Return the absolute value of the argument. + +abs(-2) +2 +help(abs),help(len), help(max), help(min), help(pow), help(round), help(sorted), help(sum), help(zip) +Help on built-in function abs in module builtins: + +abs(x, /) + Return the absolute value of the argument. + +Help on built-in function len in module builtins: + +len(obj, /) + Return the number of items in a container. + +Help on built-in function max in module builtins: + +max(...) + max(iterable, *[, default=obj, key=func]) -> value + max(arg1, arg2, *args, *[, key=func]) -> value + + With a single iterable argument, return its biggest item. The + default keyword-only argument specifies an object to return if + the provided iterable is empty. + With two or more positional arguments, return the largest argument. + +Help on built-in function min in module builtins: + +min(...) + min(iterable, *[, default=obj, key=func]) -> value + min(arg1, arg2, *args, *[, key=func]) -> value + + With a single iterable argument, return its smallest item. The + default keyword-only argument specifies an object to return if + the provided iterable is empty. + With two or more positional arguments, return the smallest argument. + +Help on built-in function pow in module builtins: + +pow(base, exp, mod=None) + Equivalent to base**exp with 2 arguments or base**exp % mod with 3 arguments + + Some types, such as ints, are able to use a more efficient algorithm when + invoked using the three argument form. + +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. + +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. + +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. + +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 + | shortest argument is exhausted. + | + | If strict is true and one of the arguments is exhausted before the others, + | raise a ValueError. + | + | >>> list(zip('abcdefg', range(3), range(4))) + | [('a', 0, 0), ('b', 1, 1), ('c', 2, 2)] + | + | Methods defined here: + | + | __getattribute__(self, name, /) + | Return getattr(self, name). + | + | __iter__(self, /) + | Implement iter(self). + | + | __next__(self, /) + | Implement next(self). + | + | __reduce__(self, /) + | Return state information for pickling. + | + | __setstate__(self, object, /) + | Set state information for unpickling. + | + | ---------------------------------------------------------------------- + | Static methods defined here: + | + | __new__(*args, **kwargs) + | Create and return a new object. See help(type) for accurate signature. + +(None, None, None, None, None, None, None, None, None) +Gg1=45 +Gg1 +45 +gg1 +1.6 +bb1=True; bb2=False +bb1;bb2 +True +False +type(bb1) + +ii1=-1234567890 +ff1=-8.9876e-12 +dv1=0b1101010 +type(dv1) + +vsm1=0o52765 +shest1=0x7109af6 +cc1=2-3j +a=3.67; b=-0.45 +cc2=complex(a,b) +cc2 +(3.67-0.45j) +ss1='Это - строка символов' +ss1="Это - строка символов" +ss1a="Это - \" строка символов \", \n \t выводимая на двух строках" +print(ss1a) +Это - " строка символов ", + выводимая на двух строках +ss1b= 'Меня зовут: \n Соловьёва Е. Д.' +print(ss1b) +Меня зовут: + Соловьёва Е. Д. + ss1b[0:23] +'Меня зовут: \n Соловьёва' +ss1b[14:23:1] +'Соловьёва' +ss1b[3:10] +'я зовут' +ss1b[14:23:2] +'Слвёа' +spis1=[111,'Spisok',5-9j] +stup=[0,0,1,1,1,1,1,1,1] +spis=[1,2,3,4, + 5,6,7, + 8,9,10] +spis +[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +spis1[-1] +(5-9j) +stup[-8::2] +[0, 1, 1, 1] +spis1[1]='Список' +spis1 +[111, 'Список', (5-9j)] + + diff --git a/TEMA2/report.md b/TEMA2/report.md index 9f44ead..2c38c28 100644 --- a/TEMA2/report.md +++ b/TEMA2/report.md @@ -120,6 +120,7 @@ ss1b[14:23:2] 'Слвёа' ``` ## 8. Сложные типы объектов. +## 8. Список ```py spis1=[111,'Spisok',5-9j] #Пример списка с 3 элементами разных типов stup=[0,0,1,1,1,1,1,1,1] @@ -160,4 +161,59 @@ spis1 [111, 78, 'New item', 'Меня зовут: \n Соловьёва Е. Д.'] spis2 [[111, 78, 'New item', 'Меня зовут: \n Соловьёва Е. Д.'], [4, 5, 6, 7]] -``` \ No newline at end of file +``` +Далее я создала список включающий объекты разных типов: число, строка, логическое значение, список. +```py +spis3=[1,"one",True,spis1] +spis3 +[1, 'one', True, [111, 78, 'New item', 'Меня зовут: \n Соловьёва Е. Д.']] +``` +## 8.2. Кортеж +Работа с кортежами - их нельзя изменять, но можно переопределять, таким образом внося изменения. +```py +kort1=(222,'Kortezh',77+8j) +kort1= kort1+(1,2) +kort1= kort1+(ss1b,) +kort2=kort1[:2]+kort1[3:] +kort1.index(2) +4 +kort1.count(222) +1 +kort1[2]=90 +Traceback (most recent call last): + File "", line 1, in + kort1[2]=90 +TypeError: 'tuple' object does not support item assignment +``` +## 8.3. Словарь +Работа со словарями. Ключи - неизменяемы. +```py +dic1={'Saratov':145, 'Orel':56, 'Vologda':45} +dic1['Orel'] +56 +dic1['Pskov']=78 +dic1 +{'Saratov': 145, 'Orel': 56, 'Vologda': 45, 'Pskov': 78} +sorted(dic1.keys()) +['Orel', 'Pskov', 'Saratov', 'Vologda'] +sorted(dic1.values()) +[45, 56, 78, 145] +dic2={1:'mean',2:'standart deviation',3:'correlation'} +dic3={'statistics':dic2,'POAS':['base','elementary','programming']} +dic3['statistics'][2] +'standart deviation' +dic4=dict([(1,['A','B','C']),(2,[4,5]),('Q','Prim'),('Stroka',ss1b)]) +dic5=dict(zip(['A','B','C','Stroka'],[16,-3,9,ss1b])) +dic5 +{'A': 16, 'B': -3, 'C': 9, 'Stroka': 'Меня зовут: \n Соловьёва Е. Д.'} +``` + +Свой словарь состоит из 5 элементов, потому что мы "сшили" два контейнера, длина определилась по минимальному кол-ву. +```py +testlist = ['pink','yellow','black','green','red'] +testkort = ('P','Y','B','G','R','T','Q') +dictest=dict(zip(testkort,testlist)) +dictest +{'P': 'pink', 'Y': 'yellow', 'B': 'black', 'G': 'green', 'R': 'red'} +``` +## 8.4. Множество