Сравнить коммиты
28 Коммитов
@ -0,0 +1,4 @@
|
|||||||
|
# Протокол по Теме 1 Огарков Илья Александрович
|
||||||
|
import os
|
||||||
|
os.chdir('\\Users\\u111-05\\Desktop\\python-labs\\TEMA1')
|
||||||
|
import prb1
|
После Ширина: | Высота: | Размер: 49 KiB |
После Ширина: | Высота: | Размер: 10 KiB |
После Ширина: | Высота: | Размер: 32 KiB |
@ -1,2 +1,5 @@
|
|||||||
name = input("Как Вас зовут? ")
|
#Программа по Теме 1 Огарков Илья Александрович
|
||||||
print("Привет,", name)
|
print('Hello')
|
||||||
|
h=input('Your name=')
|
||||||
|
import os
|
||||||
|
os.chdir('\\Users\\u111-05\\Desktop\\python-labs\\TEMA1')
|
||||||
|
@ -0,0 +1,384 @@
|
|||||||
|
<h1 align="center">Отчёт по теме 1</h1>
|
||||||
|
|
||||||
|
**Выполнил Огарков Илья, А-03-23**
|
||||||
|
|
||||||
|
## 1 Изучение среды IDLE
|
||||||
|
|
||||||
|
## 1.1 Настройка текущего каталога
|
||||||
|
|
||||||
|
```
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main)
|
||||||
|
$ git remote add upstream http://uit.mpei.ru/git/main/python-labs.git
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main)
|
||||||
|
$ git fetch upstream
|
||||||
|
From http://uit.mpei.ru/git/main/python-labs
|
||||||
|
* [new branch] main -> upstream/main
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main)
|
||||||
|
$ git stash push
|
||||||
|
No local changes to save
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main)
|
||||||
|
$ git rebase upstream/main
|
||||||
|
Current branch main is up to date.
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main)
|
||||||
|
$ git stash pop
|
||||||
|
No stash entries found.
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main)
|
||||||
|
$ cd
|
||||||
|
.git/ TEMA0/ TEMA3/ TEMA6/ TEMA9/
|
||||||
|
.gitignore TEMA1/ TEMA4/ TEMA7/
|
||||||
|
README.md TEMA2/ TEMA5/ TEMA8/
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs (main)
|
||||||
|
$ cd TEMA1
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main)
|
||||||
|
$ touch report.md
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main)
|
||||||
|
$ git status
|
||||||
|
On branch main
|
||||||
|
Your branch is up to date with 'origin/main'.
|
||||||
|
|
||||||
|
Untracked files:
|
||||||
|
(use "git add <file>..." to include in what will be committed)
|
||||||
|
report.md
|
||||||
|
|
||||||
|
nothing added to commit but untracked files present (use "git add" to track)
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main)
|
||||||
|
$ git add report.md
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main)
|
||||||
|
$ git status
|
||||||
|
On branch main
|
||||||
|
Your branch is up to date with 'origin/main'.
|
||||||
|
|
||||||
|
Changes to be committed:
|
||||||
|
(use "git restore --staged <file>..." to unstage)
|
||||||
|
new file: report.md
|
||||||
|
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main)
|
||||||
|
$ git commit -m "first commit"
|
||||||
|
[main 502c4c5] first commit
|
||||||
|
Committer: Пользователь № 5 аудитории Ж-111 <u111-05@public.mpei.local>
|
||||||
|
Your name and email address were configured automatically based
|
||||||
|
on your username and hostname. Please check that they are accurate.
|
||||||
|
You can suppress this message by setting them explicitly. Run the
|
||||||
|
following command and follow the instructions in your editor to edit
|
||||||
|
your configuration file:
|
||||||
|
|
||||||
|
git config --global --edit
|
||||||
|
|
||||||
|
After doing this, you may fix the identity used for this commit with:
|
||||||
|
|
||||||
|
git commit --amend --reset-author
|
||||||
|
|
||||||
|
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||||
|
create mode 100644 TEMA1/report.md
|
||||||
|
|
||||||
|
u111-05@w10prog-04 MINGW64 ~/Desktop/python-labs/TEMA1 (main)
|
||||||
|
$ git push
|
||||||
|
Enumerating objects: 6, done.
|
||||||
|
Counting objects: 100% (6/6), done.
|
||||||
|
Delta compression using up to 4 threads
|
||||||
|
Compressing objects: 100% (3/3), done.
|
||||||
|
Writing objects: 100% (4/4), 429 bytes | 429.00 KiB/s, done.
|
||||||
|
Total 4 (delta 1), reused 1 (delta 0), pack-reused 0
|
||||||
|
remote:
|
||||||
|
remote: Create a new pull request for 'OgarkovIA:main':
|
||||||
|
remote: http://uit.mpei.ru/git/main/python-labs/compare/main...OgarkovIA:main
|
||||||
|
remote:
|
||||||
|
remote: . Processing 1 references
|
||||||
|
remote: Processed 1 references in total
|
||||||
|
To http://uit.mpei.ru/git/OgarkovIA/python-labs.git
|
||||||
|
437460a..502c4c5 main -> main
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.3-8
|
||||||
|
```python
|
||||||
|
>>> print('Hello')
|
||||||
|
Hello
|
||||||
|
>>> h=input('Your name=')
|
||||||
|
Your name=Ilya
|
||||||
|
>>>exit()
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.9 Изучите предложения главного меню
|
||||||
|
|
||||||
|
<img src="./9.PNG" alt="Описание" width="500" height="300" align="center">
|
||||||
|
|
||||||
|
|
||||||
|
## 1.10
|
||||||
|
```python
|
||||||
|
#Программа по Теме 1 Огарков Илья Александрович
|
||||||
|
print('Hello')
|
||||||
|
h=input('Your name=')
|
||||||
|
import os
|
||||||
|
os.chdir('\\Users\\u111-05\\Desktop\\python-labs\\TEMA1')
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 1.11
|
||||||
|
|
||||||
|
```python
|
||||||
|
import prb1
|
||||||
|
Hello
|
||||||
|
Your name=
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.13
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Протокол по Теме 1 Огарков Илья Александрович
|
||||||
|
import os
|
||||||
|
os.chdir('\\Users\\u111-05\\Desktop\\python-labs\\TEMA1')
|
||||||
|
import prb1
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 1.14
|
||||||
|
|
||||||
|
```python
|
||||||
|
|
||||||
|
help(print)
|
||||||
|
Help on built-in function print in module builtins:
|
||||||
|
|
||||||
|
print(*args, sep=' ', end='\n', file=None, flush=False)
|
||||||
|
Prints the values to a stream, or to sys.stdout by default.
|
||||||
|
|
||||||
|
sep
|
||||||
|
string inserted between values, default a space.
|
||||||
|
end
|
||||||
|
string appended after the last value, default a newline.
|
||||||
|
file
|
||||||
|
a file-like object (stream); defaults to the current sys.stdout.
|
||||||
|
flush
|
||||||
|
whether to forcibly flush the stream.
|
||||||
|
|
||||||
|
help(input)
|
||||||
|
Help on built-in function input in module builtins:
|
||||||
|
|
||||||
|
input(prompt='', /)
|
||||||
|
Read a string from standard input. The trailing newline is stripped.
|
||||||
|
|
||||||
|
The prompt string, if given, is printed to standard output without a
|
||||||
|
trailing newline before reading input.
|
||||||
|
|
||||||
|
If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError.
|
||||||
|
On *nix systems, readline is used if available.
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.15
|
||||||
|
|
||||||
|
```python
|
||||||
|
# File: tdemo_chaos.py
|
||||||
|
# Author: Gregor Lingl
|
||||||
|
# Date: 2009-06-24
|
||||||
|
|
||||||
|
# A demonstration of chaos
|
||||||
|
|
||||||
|
from turtle import *
|
||||||
|
|
||||||
|
N = 80
|
||||||
|
|
||||||
|
def f(x):
|
||||||
|
return 3.9*x*(1-x)
|
||||||
|
|
||||||
|
def g(x):
|
||||||
|
return 3.9*(x-x**2)
|
||||||
|
|
||||||
|
def h(x):
|
||||||
|
return 3.9*x-3.9*x*x
|
||||||
|
|
||||||
|
def jumpto(x, y):
|
||||||
|
penup(); goto(x,y)
|
||||||
|
|
||||||
|
def line(x1, y1, x2, y2):
|
||||||
|
jumpto(x1, y1)
|
||||||
|
pendown()
|
||||||
|
goto(x2, y2)
|
||||||
|
|
||||||
|
def coosys():
|
||||||
|
line(-1, 0, N+1, 0)
|
||||||
|
line(0, -0.1, 0, 1.1)
|
||||||
|
|
||||||
|
def plot(fun, start, color):
|
||||||
|
pencolor(color)
|
||||||
|
x = start
|
||||||
|
jumpto(0, x)
|
||||||
|
pendown()
|
||||||
|
dot(5)
|
||||||
|
for i in range(N):
|
||||||
|
x=fun(x)
|
||||||
|
goto(i+1,x)
|
||||||
|
dot(5)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
reset()
|
||||||
|
setworldcoordinates(-1.0,-0.1, N+1, 1.1)
|
||||||
|
speed(0)
|
||||||
|
hideturtle()
|
||||||
|
coosys()
|
||||||
|
plot(f, 0.35, "blue")
|
||||||
|
plot(g, 0.35, "green")
|
||||||
|
plot(h, 0.35, "red")
|
||||||
|
# Now zoom in:
|
||||||
|
for s in range(100):
|
||||||
|
setworldcoordinates(0.5*s,-0.1, N+1, 1.1)
|
||||||
|
return "Done!"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
mainloop()
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="./15.PNG" alt="Описание" width="500" height="300" align="center">
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: cp1252 -*-
|
||||||
|
""" turtle-example-suite:
|
||||||
|
|
||||||
|
tdemo_clock.py
|
||||||
|
|
||||||
|
Enhanced clock-program, showing date
|
||||||
|
and time
|
||||||
|
------------------------------------
|
||||||
|
Press STOP to exit the program!
|
||||||
|
------------------------------------
|
||||||
|
"""
|
||||||
|
from turtle import *
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
def jump(distanz, winkel=0):
|
||||||
|
penup()
|
||||||
|
right(winkel)
|
||||||
|
forward(distanz)
|
||||||
|
left(winkel)
|
||||||
|
pendown()
|
||||||
|
|
||||||
|
def hand(laenge, spitze):
|
||||||
|
fd(laenge*1.15)
|
||||||
|
rt(90)
|
||||||
|
fd(spitze/2.0)
|
||||||
|
lt(120)
|
||||||
|
fd(spitze)
|
||||||
|
lt(120)
|
||||||
|
fd(spitze)
|
||||||
|
lt(120)
|
||||||
|
fd(spitze/2.0)
|
||||||
|
|
||||||
|
def make_hand_shape(name, laenge, spitze):
|
||||||
|
reset()
|
||||||
|
jump(-laenge*0.15)
|
||||||
|
begin_poly()
|
||||||
|
hand(laenge, spitze)
|
||||||
|
end_poly()
|
||||||
|
hand_form = get_poly()
|
||||||
|
register_shape(name, hand_form)
|
||||||
|
|
||||||
|
def clockface(radius):
|
||||||
|
reset()
|
||||||
|
pensize(7)
|
||||||
|
for i in range(60):
|
||||||
|
jump(radius)
|
||||||
|
if i % 5 == 0:
|
||||||
|
fd(25)
|
||||||
|
jump(-radius-25)
|
||||||
|
else:
|
||||||
|
dot(3)
|
||||||
|
jump(-radius)
|
||||||
|
rt(6)
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
global second_hand, minute_hand, hour_hand, writer
|
||||||
|
mode("logo")
|
||||||
|
make_hand_shape("second_hand", 125, 25)
|
||||||
|
make_hand_shape("minute_hand", 130, 25)
|
||||||
|
make_hand_shape("hour_hand", 90, 25)
|
||||||
|
clockface(160)
|
||||||
|
second_hand = Turtle()
|
||||||
|
second_hand.shape("second_hand")
|
||||||
|
second_hand.color("gray20", "gray80")
|
||||||
|
minute_hand = Turtle()
|
||||||
|
minute_hand.shape("minute_hand")
|
||||||
|
minute_hand.color("blue1", "red1")
|
||||||
|
hour_hand = Turtle()
|
||||||
|
hour_hand.shape("hour_hand")
|
||||||
|
hour_hand.color("blue3", "red3")
|
||||||
|
for hand in second_hand, minute_hand, hour_hand:
|
||||||
|
hand.resizemode("user")
|
||||||
|
hand.shapesize(1, 1, 3)
|
||||||
|
hand.speed(0)
|
||||||
|
ht()
|
||||||
|
writer = Turtle()
|
||||||
|
#writer.mode("logo")
|
||||||
|
writer.ht()
|
||||||
|
writer.pu()
|
||||||
|
writer.bk(85)
|
||||||
|
|
||||||
|
def wochentag(t):
|
||||||
|
wochentag = ["Monday", "Tuesday", "Wednesday",
|
||||||
|
"Thursday", "Friday", "Saturday", "Sunday"]
|
||||||
|
return wochentag[t.weekday()]
|
||||||
|
|
||||||
|
def datum(z):
|
||||||
|
monat = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "June",
|
||||||
|
"July", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."]
|
||||||
|
j = z.year
|
||||||
|
m = monat[z.month - 1]
|
||||||
|
t = z.day
|
||||||
|
return "%s %d %d" % (m, t, j)
|
||||||
|
|
||||||
|
def tick():
|
||||||
|
t = datetime.today()
|
||||||
|
sekunde = t.second + t.microsecond*0.000001
|
||||||
|
minute = t.minute + sekunde/60.0
|
||||||
|
stunde = t.hour + minute/60.0
|
||||||
|
try:
|
||||||
|
tracer(False) # Terminator can occur here
|
||||||
|
writer.clear()
|
||||||
|
writer.home()
|
||||||
|
writer.forward(65)
|
||||||
|
writer.write(wochentag(t),
|
||||||
|
align="center", font=("Courier", 14, "bold"))
|
||||||
|
writer.back(150)
|
||||||
|
writer.write(datum(t),
|
||||||
|
align="center", font=("Courier", 14, "bold"))
|
||||||
|
writer.forward(85)
|
||||||
|
second_hand.setheading(6*sekunde) # or here
|
||||||
|
minute_hand.setheading(6*minute)
|
||||||
|
hour_hand.setheading(30*stunde)
|
||||||
|
tracer(True)
|
||||||
|
ontimer(tick, 100)
|
||||||
|
except Terminator:
|
||||||
|
pass # turtledemo user pressed STOP
|
||||||
|
|
||||||
|
def main():
|
||||||
|
tracer(False)
|
||||||
|
setup()
|
||||||
|
tracer(True)
|
||||||
|
tick()
|
||||||
|
return "EVENTLOOP"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
mode("logo")
|
||||||
|
msg = main()
|
||||||
|
print(msg)
|
||||||
|
mainloop()
|
||||||
|
```
|
||||||
|
## Фото часов
|
||||||
|
|
||||||
|
<img src="./15clock.PNG" alt="Описание" width="500" height="300" align="center">
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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'}
|
||||||
|
```
|
@ -0,0 +1,21 @@
|
|||||||
|
```python
|
||||||
|
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,5 @@
|
|||||||
|
```python
|
||||||
|
strk=' А роза упала на лапу азора '
|
||||||
|
print(type(strk))
|
||||||
|
print(strk[::-1])
|
||||||
|
```
|
Загрузка…
Ссылка в новой задаче