Laboratory work No. 2 has been completed. Total DOMINATION

main
Ogarkov Ilya 2 дней назад
Родитель c26f4219f8
Сommit 03be55f96c

@ -0,0 +1,3 @@
strk=' А роза упала на лапу азора '
print(type(strk))
print(strk[::-1])

@ -0,0 +1,24 @@
import keyword
familia = "Ogarkov"
print(familia)
first = "O"
print(first)
sp_kw = keyword.kwlist
print(sp_kw)
sp_kw.remove("nonlocal")
print(sp_kw)
kort_nam = ("Ilya","Egor","Dima","Sasha")
print(kort_nam)
print(type(kort_nam))
kort_nam1 = ("Ivan","Zahar")
kort_nam = kort_nam +kort_nam1
print(kort_nam)
print(kort_nam.count("Dima"))
dict_bas = {"Список":[1,2,4], "Множество":{1,2,3,4},"Словарь":{"key":"value"}}
print(dict_bas)

@ -0,0 +1,232 @@
# Отчет по теме 2
Выполнил Огарков Илья, А-03-23
## 1 Начало работы
Создание текстового файла report.md
## 2 Изучение простых объектов
```python
f1=16;f2=3
f1;f2
16
3
del fl
dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'f1', 'f2']
type(f2)
<class 'int'>
del f1,f2
dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']
```
## 3 Изучение правил именований объектов Python
```python
ggl =1.6
hh1='Строка'
73sr=3
SyntaxError: invalid decimal literal
and=7
SyntaxError: invalid syntax
```
## 4
```python
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']
list_keyword=keyword.kwlist
list_keyword
['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
```python
round(2.124516361,2)
2.12
list_1 = [1,2,4]
list_2=["one","two","four"]
print(dict(zip(list_1,list_2)))
{1: 'one', 2: 'two', 4: 'four'}
```
## 6
```python
Ggl=45
ggl;Ggl
1.6
45
```
## 7 Изучение базовых типов объектов(bool,int,float,complex,str)
## 7.1
```python
bb1=True; bb2=False
bb1;bb2
True
False
type(bb1)
<class 'bool'>
```
## 7.2
```python
ii1=-1234567890
ff1=-8.9876e-12
dv1=0b1101010
vsm1=0o52765
shest1=0x7109af6
cc1=2-3j
a=3.67; b=-0.45
cc2=complex(a,b)
cc2
(3.67-0.45j)
```
## 7.3
```python
sslb = "Меня зовут:\nОгарков И.А."
print(sslb)
Меня зовут:
Огарков И.А.
print(mnogo)
Нетрудно заметить , что в результате операции
над числами разных типов получается число,
имеющее более сложный тип из тех, которые участвуют в операции.
```
#7.4
```python
ss1[0]
'Э'
ss1[8]
'р'
ss1[-2]
'о'
ss1[6:9]
'стр'
ss1[13:]
'символов'
ss1[:13]
'Это - строка '
ss1[5:-8]
' строка '
ss1[:2]
'Эт'
ss1[3:17:2]
' тоасм'
ss1[17:3:-2]
'омсаот '
ss1=ss1[:4]+"="+ss1[5:]
```
## 8 Изучение более сложных объектов
## 8.1
```python
spis1=[111,'Spisok',5-9j]
stup=[0,0,1,1,1,1,1,1,1]
spis1[-1]
(5-9j)
stup[-8::2]
[0, 1, 1, 1]
spis1[1]='Список'
len(spis1)
3
help(spis1.append)
Help on built-in function append:
append(object, /) method of builtins.list instance
Append object to the end of the list.
spis1.append('New item')
spis1+['New item']
[111, 'Список', (5-9j), 'New item', 'New item']
spis1.pop(1)
'Список'
spis2=[spis1,[4,5,6,7]
]
spis2[0][1]
(5-9j)
spis2[0][1]=78
spis1
[111, 78, 'New item']
list_object = [[1,2,3],["ssadd","dada","fff"],True,0.456]
list_object
[[1, 2, 3], ['ssadd', 'dada', 'fff'], True, 0.456]
```
## 8.2
```python
kort1= kort1+(sslb,)
kort2=kort1[:2]+kort1[3:]
kort1;kort2
(222, 'Kortezh', (77+8j), 1, 2, 'Меня зовут:\n Огарков И.А.')
(222, 'Kortezh', 1, 2, 'Меня зовут:\n Огарков И.А.')
kort1.index(2)
4
kort1.count(222)
1
kort1[2]=90
Traceback (most recent call last):
File "<pyshell#117>", line 1, in <module>
kort1[2]=90
TypeError: 'tuple' object does not support item assignment
tuple_object = ((1,2,3),("ssadd","dada","fff"),True,0.456)
tuple_object
((1, 2, 3), ('ssadd', 'dada', 'fff'), True, 0.456)
```
##8.3
```python
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',sslb)])
dic5=dict(zip(['A','B','C','Stroka'],[16,-3,9,sslb]))
kort_object = (1,2,3,4,5,6,7)
list_object = ["one","two","three","four","five"]
print(dict(zip(kort_object,list_object)))
{1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five'}
print(len(dict(zip(kort_object,list_object))))
5
AVTI={'Курс I':[22,23,17,24,30,29,28,25,23,0,4,31,30,33,18,12,27],'Курс II':[18,16,12,15,29,18,21,23,13,0,4,20,31,26,16,], 'Курс III':[17,12,0,6,17,15,19,19,0,0,5,17,22,18,12], 'Курс IV':[27,16,0,13,17,15,19,20,0,0,2,15,18,16,17]}
AVTI['Курс III'][5]
15
```
## 8.4
```python
mnoz1={'двигатель','датчик','линия связи','датчик','микропроцессор','двигатель'}
mnoz1
{'двигатель', 'микропроцессор', 'датчик', 'линия связи'}
len(mnoz1)
4
'датчик' in mnoz1
True
mnoz1.add('реле')
mnoz1.remove('линия связи')
set_object = {1,"1",True,1.0}
len(set_object)
2
set_object
{1, '1'}
```
Загрузка…
Отмена
Сохранить