#КалькуляторЗаработка
Код из видео:
from tkinter import *
def calculation():
earnings = float(hourly.get()) * float(hours.get())
result['text'] = f"{name.get()} заработал {earnings}Р на этой неделе."
result.pack()
root = Tk()
root.title('Калькулятор заработка')
root.geometry('500x310')
root.resizable(width=False, height=False)
root['bg'] = 'black'
Label(root, text='Введите имя сотрудника: ', font='Arial 15 bold', fg='lime', bg='black').pack(pady=5)
name = Entry(root, font='Arial 13 bold')
name.pack(pady=5)
Label(root, text='Почасовая оплата сотрудника: ', font='Arial 15 bold', fg='lime', bg='black').pack(pady=5)
hourly = Entry(root, font='Arial 13 bold')
hourly.pack(pady=5)
Label(root, text='Кол-во часов прорпботанных за неделю: ', font='Arial 15 bold', fg='lime', bg='black').pack(pady=5)
hours = Entry(root, font='Arial 13 bold')
hours.pack(pady=5)
btn = Button(root, text='Рассчитать', font='Arial 15 bold', command=calculation)
btn.pack(pady=5)
result = Label(root, font='Arial 15 bold', fg='lime', bg='black')
root.mainloop()
Код из видео:
from tkinter import *
def calculation():
earnings = float(hourly.get()) * float(hours.get())
result['text'] = f"{name.get()} заработал {earnings}Р на этой неделе."
result.pack()
root = Tk()
root.title('Калькулятор заработка')
root.geometry('500x310')
root.resizable(width=False, height=False)
root['bg'] = 'black'
Label(root, text='Введите имя сотрудника: ', font='Arial 15 bold', fg='lime', bg='black').pack(pady=5)
name = Entry(root, font='Arial 13 bold')
name.pack(pady=5)
Label(root, text='Почасовая оплата сотрудника: ', font='Arial 15 bold', fg='lime', bg='black').pack(pady=5)
hourly = Entry(root, font='Arial 13 bold')
hourly.pack(pady=5)
Label(root, text='Кол-во часов прорпботанных за неделю: ', font='Arial 15 bold', fg='lime', bg='black').pack(pady=5)
hours = Entry(root, font='Arial 13 bold')
hours.pack(pady=5)
btn = Button(root, text='Рассчитать', font='Arial 15 bold', command=calculation)
btn.pack(pady=5)
result = Label(root, font='Arial 15 bold', fg='lime', bg='black')
root.mainloop()
#ПриложениеГенераторАнекдотов
Код из видео:
from tkinter import *
import pyjokes
from googletrans import Translator
def generate():
joke = pyjokes.get_joke()
a = translator.translate(joke, dest='ru')
t.delete('1.0', END)
t.insert('1.0', a.text)
root = Tk()
root.title('Генератор анекдотов')
root.geometry('500x300')
root.resizable(width=False, height=False)
translator = Translator()
btn = Button(root, text='Сгенерировать анекдот', font='Arial 16 bold', command=generate)
btn.pack(pady=10)
t = Text(root, font='Arial 16 bold',
pady=10,
padx=10,
wrap=WORD
)
t.pack()
root.mainloop()
Код из видео:
from tkinter import *
import pyjokes
from googletrans import Translator
def generate():
joke = pyjokes.get_joke()
a = translator.translate(joke, dest='ru')
t.delete('1.0', END)
t.insert('1.0', a.text)
root = Tk()
root.title('Генератор анекдотов')
root.geometry('500x300')
root.resizable(width=False, height=False)
translator = Translator()
btn = Button(root, text='Сгенерировать анекдот', font='Arial 16 bold', command=generate)
btn.pack(pady=10)
t = Text(root, font='Arial 16 bold',
pady=10,
padx=10,
wrap=WORD
)
t.pack()
root.mainloop()
#ДиктофонНаPython
Код из видео:
import sounddevice
from scipy.io.wavfile import write
def voice_recorder(seconds, file):
print('Запись началась')
recording = sounddevice.rec((seconds * 44100), samplerate=44100, channels=2)
sounddevice.wait()
write(file, 44100, recording)
print('Запись завершена')
voice_recorder(10, 'Запись.wav')
Код из видео:
import sounddevice
from scipy.io.wavfile import write
def voice_recorder(seconds, file):
print('Запись началась')
recording = sounddevice.rec((seconds * 44100), samplerate=44100, channels=2)
sounddevice.wait()
write(file, 44100, recording)
print('Запись завершена')
voice_recorder(10, 'Запись.wav')
#КонвертацияДанныхИФайловВPDF
Код из видео:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', size=25)
with open('Test.txt', 'r') as f:
for i in f:
pdf.cell(200, 10, txt=i, ln=1, align='C')
pdf.output('pdfTest.pdf')
Код из видео:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', size=25)
with open('Test.txt', 'r') as f:
for i in f:
pdf.cell(200, 10, txt=i, ln=1, align='C')
pdf.output('pdfTest.pdf')
#ПростоеВебПриложение
Код из видео:
Файл main.py:
import eel
eel.init('web')
eel.start('index.html', size=(700, 700))
Файл index.html:
<html>
<head>
<title>Журнал</title>
<meta charset="UTF-8">
<style type="text/css">
body{
background: #FFDEAD;
}
table{
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
td, th{
border: 2px solid black;
}
</style>
</head>
<body>
<h1 align="center">Журнал</h1>
<table id="journal">
<tr>
<th>Абрамович</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Гордон</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Карен</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Юрий</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Юлий</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
<script>
let cells = document.querySelectorAll("#journal td");
for (let cell of cells) {
let mark = Math.floor(Math.random() * 4) + 2;
let colors = {
2: "red",
3: "yellow",
4: "green",
5: "lime",
};
cell.innerText = String(mark);
cell.style.backgroundColor = colors[mark];
}
</script>
</body>
</html>
Код из видео:
Файл main.py:
import eel
eel.init('web')
eel.start('index.html', size=(700, 700))
Файл index.html:
<html>
<head>
<title>Журнал</title>
<meta charset="UTF-8">
<style type="text/css">
body{
background: #FFDEAD;
}
table{
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
td, th{
border: 2px solid black;
}
</style>
</head>
<body>
<h1 align="center">Журнал</h1>
<table id="journal">
<tr>
<th>Абрамович</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Гордон</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Карен</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Юрий</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Юлий</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
<script>
let cells = document.querySelectorAll("#journal td");
for (let cell of cells) {
let mark = Math.floor(Math.random() * 4) + 2;
let colors = {
2: "red",
3: "yellow",
4: "green",
5: "lime",
};
cell.innerText = String(mark);
cell.style.backgroundColor = colors[mark];
}
</script>
</body>
</html>
👍1
#ПроверкаНаОпечатки
Код из видео:
from spellchecker import SpellChecker
spell = SpellChecker(language='ru')
with open('text.txt', 'r', encoding='utf-8') as f:
misspelled = f.read()
misspelled = misspelled.split(' ')
print(misspelled)
misspelled = spell.unknown(misspelled)
print(misspelled)
for word in misspelled:
print(spell.correction(word))
Код из видео:
from spellchecker import SpellChecker
spell = SpellChecker(language='ru')
with open('text.txt', 'r', encoding='utf-8') as f:
misspelled = f.read()
misspelled = misspelled.split(' ')
print(misspelled)
misspelled = spell.unknown(misspelled)
print(misspelled)
for word in misspelled:
print(spell.correction(word))
#СозданиеГифки
Код из видео:
from moviepy.editor import *
clip = (VideoFileClip('video.mp4').subclip(3, 7).resize(0.5))
clip.write_gif('gifka.gif')
Код из видео:
from moviepy.editor import *
clip = (VideoFileClip('video.mp4').subclip(3, 7).resize(0.5))
clip.write_gif('gifka.gif')