You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
2.2 KiB
114 lines
2.2 KiB
---
|
|
title: Классная работа 10В
|
|
excerpt: Все, что показывал в классе тут.
|
|
date: '2023-11-09'
|
|
tags:
|
|
- Информатика
|
|
- Программирование
|
|
- Python
|
|
- Задачи
|
|
---
|
|
|
|
<TableOfContents>
|
|
|
|
- [Урок 10.11.23](#урок-10.11.23)
|
|
|
|
</TableOfContents>
|
|
|
|
## Урок 08.11.23
|
|
|
|
~~~python
|
|
# Импортируем библиотеку pygame
|
|
import pygame
|
|
# Импортируем системную функцию exit
|
|
from sys import exit
|
|
|
|
# Инициализируем pygame
|
|
pygame.init()
|
|
|
|
k = 6
|
|
|
|
wDisp = 900
|
|
hDisp = 300
|
|
|
|
display = pygame.display.set_mode((wDisp, hDisp))
|
|
|
|
PURPLE = (156, 39, 176)
|
|
INDIGO = (63, 81, 181)
|
|
BLUE = (33, 150, 243)
|
|
|
|
wS = wDisp/3
|
|
hS = hDisp
|
|
|
|
pygame.draw.rect(display, PURPLE, ((wDisp/2)-(wS/2)-wS, (hDisp/2)-(hS/2), wS, hS))
|
|
pygame.draw.rect(display, INDIGO, ((wDisp/2)-(wS/2), (hDisp/2)-(hS/2), wS, hS))
|
|
pygame.draw.rect(display, BLUE, ((wDisp/2)-(wS/2)+wS, (hDisp/2)-(hS/2), wS, hS))
|
|
|
|
# Основной цикл игры
|
|
while True:
|
|
# Ждем события (действия пользователя)
|
|
for event in pygame.event.get():
|
|
# Если нажали на крестик,
|
|
# то закрываем окно
|
|
if event.type == pygame.QUIT:
|
|
pygame.quit()
|
|
exit()
|
|
|
|
# Обновляем поверхность игры
|
|
# на каждом шаге основного цикла игры
|
|
pygame.display.update()
|
|
~~~
|
|
|
|
## Урок 14.11.23
|
|
|
|
~~~python
|
|
# main.py
|
|
from mylib import speed
|
|
mas = [[45,0,67],[67,0,222],[43,0,45],[78,0,321]]
|
|
|
|
summ = 0
|
|
|
|
for i in range(len(mas)):
|
|
summ = summ + speed(mas[i][0],mas[i][1],mas[i][2])
|
|
|
|
print(summ)
|
|
~~~
|
|
|
|
~~~python
|
|
# mylib.py
|
|
|
|
def speed(v,t,s):
|
|
summ = 0
|
|
if v == 0:
|
|
summ = (s/t)
|
|
if t == 0:
|
|
summ = (s/v)
|
|
if s == 0:
|
|
summ = (t*v)
|
|
return summ
|
|
~~~
|
|
|
|
## Урок 15.11.23
|
|
|
|
~~~python
|
|
# main.py
|
|
from mylib import strength_elasticity
|
|
|
|
mas = [[0, 200, 45], [56, 0, 8], [234, 14, 0]]
|
|
|
|
for i in range(len(mas)):
|
|
print(strength_elasticity(mas[i][0],mas[i][1],mas[i][2]))
|
|
~~~
|
|
|
|
~~~python
|
|
# mylib.py
|
|
|
|
def strength_elasticity(f, x, k):
|
|
if f == 0:
|
|
return k*x
|
|
if x == 0:
|
|
return f/k
|
|
if k == 0:
|
|
return f/x
|
|
|
|
~~~ |