#ПриложениеГенераторАнекдотов
Код из видео:
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')
#МатрицаНаPython
Код из видео:
from tkinter import *
import random
import time
root = Tk()
root.title('Матрица')
root.geometry('700x700+300+300')
root.resizable(width=False, height=False)
c = Canvas(root, width=700, height=700, bg='black')
c.pack()
alphabet = 'qwertyuiop[]{}asdfghjkl;zxcvbnm<>?/|'
alphabet.split()
print(alphabet)
print(len(alphabet))
h = 0
while True:
c.delete('t' + str(h))
for i in range(1, 35):
r = random.randint(0, 35)
ct = c.create_text(20 * i, h, text=str(alphabet[r]), fill='lime', font=('Comic Sans MS', 11), tag='t' + str(h))
rdm = random.randint(1, 10)
for j in range(10):
c.move(ct, 0, rdm)
c.update()
h += 20
if h >= 650:
h = 0
time.sleep(0.1)
Код из видео:
from tkinter import *
import random
import time
root = Tk()
root.title('Матрица')
root.geometry('700x700+300+300')
root.resizable(width=False, height=False)
c = Canvas(root, width=700, height=700, bg='black')
c.pack()
alphabet = 'qwertyuiop[]{}asdfghjkl;zxcvbnm<>?/|'
alphabet.split()
print(alphabet)
print(len(alphabet))
h = 0
while True:
c.delete('t' + str(h))
for i in range(1, 35):
r = random.randint(0, 35)
ct = c.create_text(20 * i, h, text=str(alphabet[r]), fill='lime', font=('Comic Sans MS', 11), tag='t' + str(h))
rdm = random.randint(1, 10)
for j in range(10):
c.move(ct, 0, rdm)
c.update()
h += 20
if h >= 650:
h = 0
time.sleep(0.1)
👍1