#Анаграммы
Код из видео:
from random import choice, sample
words = ['питон', 'мышь', 'клавиатура', 'телефон']
word = choice(words)
wordMix = sample(word, k=len(word))
print('Загаданное слово: ' + ''.join(wordMix))
while True:
guess = input('Введите вашу догадку: ')
if guess == word:
print('Вы угадали! \nХотите ещё разок (да/нет)?')
what = input('Ваш ответ: ')
if what == 'да':
word = choice(words)
wordMix = sample(word, k=len(word))
print('Загаданное слово ' + ''.join(wordMix))
continue
else:
break
else:
print('Вы не угадали, попробуйте ещё раз')
Код из видео:
from random import choice, sample
words = ['питон', 'мышь', 'клавиатура', 'телефон']
word = choice(words)
wordMix = sample(word, k=len(word))
print('Загаданное слово: ' + ''.join(wordMix))
while True:
guess = input('Введите вашу догадку: ')
if guess == word:
print('Вы угадали! \nХотите ещё разок (да/нет)?')
what = input('Ваш ответ: ')
if what == 'да':
word = choice(words)
wordMix = sample(word, k=len(word))
print('Загаданное слово ' + ''.join(wordMix))
continue
else:
break
else:
print('Вы не угадали, попробуйте ещё раз')
#ПриложееиеАнаграммы
Код из видео:
from random import choice, sample
from tkinter import *
from tkinter import messagebox
def start():
global word, guessEntry, wordMix
btnYes.place_forget()
btnNo.place_forget()
btn['text'] = 'Проверить'
btn['width'] = 10
btn['command'] = check
btn.place(relx=0.5, y=130, anchor=CENTER)
word = choice(words)
wordMix = sample(word, k=len(word))
label1['text'] = 'Загаданное слово: ' + ''.join(wordMix)
guessEntry = Entry(root, font='Arial 15 bold')
guessEntry.place(relx=0.5, y=80, anchor=CENTER)
def check():
guess = guessEntry.get()
if guess == word:
guessEntry.place_forget()
btn.place_forget()
label1['text'] = 'Вы угадали!\n Хотите ещё раз?'
btnYes.place(x=120, y=70)
btnNo.place(x=220, y=70)
else:
label1['text'] = 'Вы не угадали, попробуйте ещё раз\nЗагаданное слово: ' + ''.join(wordMix)
def exitGame():
answer = messagebox.askokcancel('Выход', 'Вы точно хотите выйти?')
if answer:
root.destroy()
root = Tk()
root.title('Анаграммы')
root.geometry('400x200')
root.resizable(width=False, height=False)
words = ['питон', 'мышь', 'клавиатура', 'телефон']
label1 = Label(root, text='', font='Arial 15 bold')
label1.place(relx=0.5, y=30, anchor=CENTER)
btn = Button(root, text='Начать', font='Arial 15 bold', width=20, command=start)
btn.place(relx=0.5, y=90, anchor=CENTER)
btnYes = Button(root, text='Да', font='Arial 15 bold', width=5, command=start)
btnNo = Button(root, text='Нет', font='Arial 15 bold', width=5, command=exitGame)
root.mainloop()
Код из видео:
from random import choice, sample
from tkinter import *
from tkinter import messagebox
def start():
global word, guessEntry, wordMix
btnYes.place_forget()
btnNo.place_forget()
btn['text'] = 'Проверить'
btn['width'] = 10
btn['command'] = check
btn.place(relx=0.5, y=130, anchor=CENTER)
word = choice(words)
wordMix = sample(word, k=len(word))
label1['text'] = 'Загаданное слово: ' + ''.join(wordMix)
guessEntry = Entry(root, font='Arial 15 bold')
guessEntry.place(relx=0.5, y=80, anchor=CENTER)
def check():
guess = guessEntry.get()
if guess == word:
guessEntry.place_forget()
btn.place_forget()
label1['text'] = 'Вы угадали!\n Хотите ещё раз?'
btnYes.place(x=120, y=70)
btnNo.place(x=220, y=70)
else:
label1['text'] = 'Вы не угадали, попробуйте ещё раз\nЗагаданное слово: ' + ''.join(wordMix)
def exitGame():
answer = messagebox.askokcancel('Выход', 'Вы точно хотите выйти?')
if answer:
root.destroy()
root = Tk()
root.title('Анаграммы')
root.geometry('400x200')
root.resizable(width=False, height=False)
words = ['питон', 'мышь', 'клавиатура', 'телефон']
label1 = Label(root, text='', font='Arial 15 bold')
label1.place(relx=0.5, y=30, anchor=CENTER)
btn = Button(root, text='Начать', font='Arial 15 bold', width=20, command=start)
btn.place(relx=0.5, y=90, anchor=CENTER)
btnYes = Button(root, text='Да', font='Arial 15 bold', width=5, command=start)
btnNo = Button(root, text='Нет', font='Arial 15 bold', width=5, command=exitGame)
root.mainloop()
👍1
#ЗаписьВидеоСЭкрана
Код из видео:
import cv2
import numpy as np
import pyautogui
SCREEN_SIZE = (1920, 1080)
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter("output.avi", fourcc, 20.0, (SCREEN_SIZE))
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
cv2.imshow("screenshot", frame)
if cv2.waitKey(1) == ord("q"):
break
cv2.destroyAllWindows()
out.release()
Код из видео:
import cv2
import numpy as np
import pyautogui
SCREEN_SIZE = (1920, 1080)
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter("output.avi", fourcc, 20.0, (SCREEN_SIZE))
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
cv2.imshow("screenshot", frame)
if cv2.waitKey(1) == ord("q"):
break
cv2.destroyAllWindows()
out.release()
👍2
#МонтажВидео
Код из видео:
from moviepy.editor import *
clip_1 = VideoFileClip('One.mp4')
clip_2 = VideoFileClip('Two.mp4')
# Склейка видео в одно
final_clip = concatenate_videoclips([clip_1, clip_2])
# Обрезать видео с 3 по 7 сек.
final_clip = final_clip.subclip(3, 7)
# Уменьшаем громкость видео
final_clip = final_clip.volumex(0.5)
# Узнаём длительность видео
duration = clip.duration
# Выводим длительность видео
print("Duration : " + str(duration))
# Сохраняем видео
final_clip.write_videofile('Three.mp4')
Код из видео:
from moviepy.editor import *
clip_1 = VideoFileClip('One.mp4')
clip_2 = VideoFileClip('Two.mp4')
# Склейка видео в одно
final_clip = concatenate_videoclips([clip_1, clip_2])
# Обрезать видео с 3 по 7 сек.
final_clip = final_clip.subclip(3, 7)
# Уменьшаем громкость видео
final_clip = final_clip.volumex(0.5)
# Узнаём длительность видео
duration = clip.duration
# Выводим длительность видео
print("Duration : " + str(duration))
# Сохраняем видео
final_clip.write_videofile('Three.mp4')
#УбегающаяКнопка
Код из видео:
from tkinter import *
from tkinter import messagebox
import random
def no():
messagebox.showinfo(' ', 'Спасибо! Ваш голос учтён!')
quit()
def motionMouse(event):
btnYes.place(x=random.randint(0, 500), y=random.randint(0, 500))
root = Tk()
root.geometry('600x600')
root.title('Опрос')
root.resizable(width=False, height=False)
root['bg'] = 'white'
label = Label(root, text='Вы хотите увеличить ЗП?', font='Arial 20 bold', bg='white').pack()
btnYes = Button(root, text='Да', font='Arial 20 bold')
btnYes.place(x=170, y=100)
btnYes.bind('<Enter>', motionMouse)
btnNo = Button(root, text='Нет', font='Arial 20 bold', command=no).place(x=350, y=100)
root.mainloop()
Код из видео:
from tkinter import *
from tkinter import messagebox
import random
def no():
messagebox.showinfo(' ', 'Спасибо! Ваш голос учтён!')
quit()
def motionMouse(event):
btnYes.place(x=random.randint(0, 500), y=random.randint(0, 500))
root = Tk()
root.geometry('600x600')
root.title('Опрос')
root.resizable(width=False, height=False)
root['bg'] = 'white'
label = Label(root, text='Вы хотите увеличить ЗП?', font='Arial 20 bold', bg='white').pack()
btnYes = Button(root, text='Да', font='Arial 20 bold')
btnYes.place(x=170, y=100)
btnYes.bind('<Enter>', motionMouse)
btnNo = Button(root, text='Нет', font='Arial 20 bold', command=no).place(x=350, y=100)
root.mainloop()
👍5
#СлайдШоуНаПитоне
Код из видео:
from moviepy.editor import *
import os
directory = 'Путь к папке с изображениями'
files = os.listdir(directory)
imges = list(filter(lambda x: x.endswith('.jpg'), files))
clips = [ImageClip(m).set_duration(2) for m in imges]
final_clip = concatenate_videoclips(clips, method='compose')
final_clip.write_videofile('test.mp4', fps=24)
Код из видео:
from moviepy.editor import *
import os
directory = 'Путь к папке с изображениями'
files = os.listdir(directory)
imges = list(filter(lambda x: x.endswith('.jpg'), files))
clips = [ImageClip(m).set_duration(2) for m in imges]
final_clip = concatenate_videoclips(clips, method='compose')
final_clip.write_videofile('test.mp4', fps=24)
Небольшой сборник интересных видео с канала.
https://www.youtube.com/watch?v=AjlK8Y338hk
https://www.youtube.com/watch?v=AjlK8Y338hk
YouTube
5 интересных программ на python (питон) | Сборник
5 интересных программ на python (питон) | Сборник
★ Телеграм канал: https://t.me/programmersGuide_1
★ Группа ВК: https://vk.com/club123524808
► Поддержать автора:
https://www.donationalerts.com/r/it_start
Тайм-коды:
00:00 Будильник на python
11:59 Запись…
★ Телеграм канал: https://t.me/programmersGuide_1
★ Группа ВК: https://vk.com/club123524808
► Поддержать автора:
https://www.donationalerts.com/r/it_start
Тайм-коды:
00:00 Будильник на python
11:59 Запись…
#СокращательСсылок
Код из видео:
import pyshorteners
from tkinter import *
from tkinter import ttk, messagebox
def short():
s = pyshorteners.Shortener()
sohr = beforeLink.get()
afterLink.delete(0, END)
afterLink.insert(0, s.tinyurl.short(sohr))
root = Tk()
root.title('Сокращатель ссылок')
root.geometry('400x150')
root.resizable(width=False, height=False)
beforeLinkLabel = Label(root, text="Вставьте ссылку")
beforeLinkLabel.place(x=10, y=10)
beforeLink = ttk.Entry(root, width=40, font="Arial 13")
beforeLink.place(x=10, y=30)
btn = ttk.Button(root, text="Сократить", command=short)
btn.place(relx=0.5, y=80, anchor=CENTER)
afterLinkLabel = Label(root, text="Результат:")
afterLinkLabel.place(x=10, y=85)
afterLink = ttk.Entry(root, width=40, font="Arial 13", text="")
afterLink.place(x=10, y=105)
root.mainloop()
Код из видео:
import pyshorteners
from tkinter import *
from tkinter import ttk, messagebox
def short():
s = pyshorteners.Shortener()
sohr = beforeLink.get()
afterLink.delete(0, END)
afterLink.insert(0, s.tinyurl.short(sohr))
root = Tk()
root.title('Сокращатель ссылок')
root.geometry('400x150')
root.resizable(width=False, height=False)
beforeLinkLabel = Label(root, text="Вставьте ссылку")
beforeLinkLabel.place(x=10, y=10)
beforeLink = ttk.Entry(root, width=40, font="Arial 13")
beforeLink.place(x=10, y=30)
btn = ttk.Button(root, text="Сократить", command=short)
btn.place(relx=0.5, y=80, anchor=CENTER)
afterLinkLabel = Label(root, text="Результат:")
afterLinkLabel.place(x=10, y=85)
afterLink = ttk.Entry(root, width=40, font="Arial 13", text="")
afterLink.place(x=10, y=105)
root.mainloop()
#ВиселицаНаPython
Код из видео:
from random import choice
HANGMAN = (
"""
------
| |
|
|
|
|
|
----------
""",
"""
------
| |
| O
|
|
|
|
----------
""",
"""
------
| |
| O
| |
|
|
|
----------
""",
"""
------
| |
| O
| /|
|
|
|
----------
""",
"""
------
| |
| O
| /|\\
|
|
|
----------
""",
"""
------
| |
| O
| /|\\
| /
|
|
----------
""",
"""
------
| |
| O
| /|\\
| / \\
|
|
----------
"""
)
max_wrong = len(HANGMAN)
WORDS = ('питон', 'игра', 'программирование')
word = choice(WORDS)
so_far = '_' * len(word)
wrong = 0
used = []
while wrong < max_wrong and so_far != word:
print(HANGMAN[wrong])
print('\nВы использовали следующие буквы:\n', used)
print('\nНа данный момент слово выглядит вот так:\n', so_far)
guess = input('\nВведите своё предположение: ')
while guess in used:
print('Вы уже угадали букву', guess)
guess = input('Введите своё предположение: ')
used.append(guess)
if guess in word:
print('\nДа! \'' + guess + '\' есть в слове!')
new = ''
for i in range(len(word)):
if guess == word[i]:
new += guess
else:
new += so_far[i]
so_far = new
else:
print('\nИзвините, буквы \'' + guess + '\' нет в слове.')
wrong += 1
if wrong == max_wrong:
print(HANGMAN[wrong])
print('\nТебя повесили!')
else:
print('\nВы угадали слово!')
print('\nЗагаданное слово было \'' + word + '\'')
Код из видео:
from random import choice
HANGMAN = (
"""
------
| |
|
|
|
|
|
----------
""",
"""
------
| |
| O
|
|
|
|
----------
""",
"""
------
| |
| O
| |
|
|
|
----------
""",
"""
------
| |
| O
| /|
|
|
|
----------
""",
"""
------
| |
| O
| /|\\
|
|
|
----------
""",
"""
------
| |
| O
| /|\\
| /
|
|
----------
""",
"""
------
| |
| O
| /|\\
| / \\
|
|
----------
"""
)
max_wrong = len(HANGMAN)
WORDS = ('питон', 'игра', 'программирование')
word = choice(WORDS)
so_far = '_' * len(word)
wrong = 0
used = []
while wrong < max_wrong and so_far != word:
print(HANGMAN[wrong])
print('\nВы использовали следующие буквы:\n', used)
print('\nНа данный момент слово выглядит вот так:\n', so_far)
guess = input('\nВведите своё предположение: ')
while guess in used:
print('Вы уже угадали букву', guess)
guess = input('Введите своё предположение: ')
used.append(guess)
if guess in word:
print('\nДа! \'' + guess + '\' есть в слове!')
new = ''
for i in range(len(word)):
if guess == word[i]:
new += guess
else:
new += so_far[i]
so_far = new
else:
print('\nИзвините, буквы \'' + guess + '\' нет в слове.')
wrong += 1
if wrong == max_wrong:
print(HANGMAN[wrong])
print('\nТебя повесили!')
else:
print('\nВы угадали слово!')
print('\nЗагаданное слово было \'' + word + '\'')
👍1