import math
while True:
a = int(input("ax^2+bx+c=0 / a: "))
b = int(input("ax^2+bx+c=0 / b: "))
c = int(input("ax^2+bx+c=0 / c: "))
d = b ** 2 - 4 * a * c
if d > 0:
x1 = (-b + math.sqrt(d)) / (2 * a)
x2 = (-b - math.sqrt(d)) / (2 * a)
print(f'Корней: 2. \n x1 = {x1}')
print(f'Корней: 2. \n x2 = {x2}')
elif d == 0:
x1 = -b / (2 * a)
print(f'Корень: 1. \n x1 = {x1}')
else:
print("Корней: 0")
@upload_router.post('')
async def upload_file(
request: Request,
file: Annotated[UploadFile, File()],
):
file_content = await file.read()
await s3_client.upload_fileobj(
io.BytesIO(file_content),
'bucket-name',
f'{unique_filename}_{file.filename}'
)
from datetime import datetime, timedelta
def find_youngest_birthday(employees, current_date):
current_date = datetime.strptime(current_date, '%d.%m.%Y')
start_date = current_date + timedelta(days=1)
end_date = current_date + timedelta(days=7)
youngest_employee = None
youngest_birthday = None
youngest_age = None
for employee in employees:
birthday = datetime.strptime(employee['birthday'], '%d.%m.%Y')
birthday_this_year = birthday.replace(year=current_date.year)
if start_date <= birthday_this_year <= end_date:
age = current_date.year - birthday.year
if current_date.month < birthday.month or (current_date.month == birthday.month and current_date.day < birthday.day):
age -= 1
if youngest_employee is None or age < youngest_age:
youngest_employee = employee
youngest_age = age
youngest_birthday = birthday_this_year
elif age == youngest_age and birthday_this_year > youngest_birthday:
youngest_employee = employee
youngest_birthday = birthday_this_year
if youngest_employee:
return f"{youngest_employee['name']} {youngest_employee['surname']}"
else:
return "Дни рождения не планируются"
current_date = input()
n = int(input())
employees = []
for _ in range(n):
name, surname, birthday = input().split()
employees.append({'name': name, 'surname': surname, 'birthday': birthday})
print(find_youngest_birthday(employees, current_date))
from dotenv import load_dotenv
import os
load_dotenv()
TOKEN = os.getenv("TINKOFF_INVEST_TOKEN")
TINKOFF_INVEST_TOKEN=мой токен
import sounddevice as sd
import numpy as np
duration = 5
fs = 44100
print("Запись...")
recording = sd.rec(int(duration * fs), samplerate=fs, channels=2)
sd.wait()
print("Запись завершена, воспроизведение...")
sd.play(recording, fs)
sd.wait()
import os
import sys
import tkinter as tk
def resource_path(relative_path):
try:
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
root = tk.Tk()
icon_path = resource_path("icon.ico")
root.iconbitmap(icon_path)
root.mainloop()
from PIL import ImageGrab
import io
screenshot = ImageGrab.grab()
byte_io = io.BytesIO()
screenshot.save(byte_io, format='PNG')
image_bytes = byte_io.getvalue()
import subprocess
from time import sleep
class CameraMonitor:
def __init__(self):
self.IP12 = '192.168.0.100'
self.IP13 = '192.168.0.101'
self.RODOS12 = '192.168.1.100'
self.RODOS13 = '192.168.1.101'
self.fail_count = {'Купол 12': 0, 'Купол 13': 0}
self.reboot_count = {'Купол 12': 0, 'Купол 13': 0}
def ping_camera(self, ip):
cmd = f'ping {ip} -n 1 -w 100'
response = subprocess.call(cmd, stdout=subprocess.DEVNULL)
return response == 0
def cameras_checker(self):
r_dict = {'Купол 12': self.IP12, 'Купол 13': self.IP13}
while True:
for camera, ip in r_dict.items():
if self.ping_camera(ip):
print(f'Camera {camera} - OK')
self.fail_count[camera] = 0
else:
self.fail_count[camera] += 1
print(f'Camera {camera} - Died')
if self.fail_count[camera] >= 5:
self.cameras_reboot(camera)
sleep(5)
def cameras_reboot(self, camera):
if camera == 'Купол 12':
ip = self.RODOS12
else:
ip = self.RODOS13
self.reboot_count[camera] += 1
print(f'Rebooting {camera} at IP {ip}')
def info(self):
for camera, count in self.reboot_count.items():
print(f'Перезагрузок {camera}: {count}')
if __name__ == "__main__":
monitor = CameraMonitor()
monitor.cameras_checker()
length = input().split()
data = [int(x) for x in length]
n = len(data)
max_area = 0
for i in range(n):
for j in range(i + 1, n):
pair_width = abs(i - j)
pair_height = min(data[i], data[j])
max_area = max(max_area, pair_height * pair_width)
print(max_area)
from ftplib import FTP
import os
ftp = FTP("tipftp")
ftp.login(user="tuserftp", passwd="tpssword")
local_dir = '/Users/tuser/Documents/py/test/'
files = ftp.nlst('/Backups/tdir/')
xml_files = [file for file in files if file.endswith('.xml')]
for file in xml_files:
local_file = os.path.join(local_dir, os.path.basename(file))
with open(local_file, 'wb') as tempfile:
ftp.retrbinary(f'RETR {file}', tempfile.write)
ftp.quit()
import requests
from bs4 import BeautifulSoup
url = 'https://goverla.ua/'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
usd_row = soup.find('div', class_='row', text=lambda t: 'USD' in t)
if usd_row:
sale_value = usd_row.find_all('div', class_='value row__value')[1].find('h3').text.strip()
usd_sale_rate = float(sale_value)
[Unit]
Description=my_prog
After=network-online.target nss-user-lookup.target
[Service]
User=pi
Group=pi
WorkingDirectory=/home/pi/www
ExecStart=/home/pi/www/env/bin/python3 /home/pi/www/run.py
Environment="PATH=/home/pi/www/env/bin:/usr/bin:/bin"
RestartSec=10
Restart=always
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
import pyautogui
import pyglet
import os
import threading
pyautogui.hotkey('win', 'e')
def play_sound():
song = pyglet.media.load('speak/yes.mp3')
song.play()
pyglet.app.run()
threading.Thread(target=play_sound).start()
print("[F.R.I.D.A.Y]: Запрос выполнен")
from aiogram import types
@dp.message_handler(content_types=types.ContentType.TEXT)
async def auto_reply(message: types.Message):
await message.answer("Спасибо за ваше сообщение!")
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://google.com")
driver.execute_script("window.localStorage.setItem('key', 'value');")
driver.execute_script("window.sessionStorage.setItem('key', 'value');")
local_storage_value = driver.execute_script("return window.localStorage.getItem('key');")
session_storage_value = driver.execute_script("return window.sessionStorage.getItem('key');