Справочник Программиста
6.29K subscribers
1.35K photos
386 videos
64 files
1.7K links
По рекламе - @it_start_programmer
Мои курсы - @courses_from_it_start_bot
Сайт - https://it-start.online/
YouTube - https://www.youtube.com/@it_start
Реклама на бирже - https://telega.in/c/programmersGuide_1

Предложить идею: @it_start_suggestion_bot
Download Telegram
#ПростаяПроверкаНадёжностиПароляНаPython
Код из видео:

import string

password = input('Введите пароль: ')

upper_case = any([1 if i in string.ascii_uppercase else 0 for i in password])
lower_case = any([1 if i in string.ascii_lowercase else 0 for i in password])
special = any([1 if i in string.punctuation else 0 for i in password])
digits = any([1 if i in string.digits else 0 for i in password])

length = len(password)

if length >= 10:
length = True
else:
length = False

characters = [upper_case, lower_case, special, digits, length]
print(characters)

score = 0
for i in range(len(characters)):
if characters[i]:
score += 1

print('Надёжность пароля: %s из 5' % score)
👍4
#ПреобразованиеКоординатВГеографическиеМестоположенияСПомощьюPython
Код из видео:

from geopy import Nominatim

coordinates = '73.783575, 93.008677'

nominaltim = Nominatim(user_agent='user')

location = nominaltim.reverse(coordinates)

print(location)
👍5
#ГолосовойПомощникНаPython
Код из видео:

import pyttsx3
import speech_recognition as sr


def listen_command():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Скажите команду: ')
r.pause_threshold = 1
r.adjust_for_ambient_noise(source, duration=1)
audio = r.listen(source)

try:
our_speech = r.recognize_google(audio, language='ru-RU')
print('Вы сказали: ' + our_speech)
return our_speech
except sr.UnknownValueError:
return 'Ошибка'
except sr.RequestError:
return 'Ошибка'


def do_this_message(message):
message = message.lower()
if 'привет' in message:
say_message('Привет!')
elif 'как дела' in message:
say_message('Хорошо')
elif 'пока' in message:
say_message('Пока')
exit()
else:
say_message('Команда не распознана!')


def say_message(message):
engine.say(message)
engine.runAndWait()
print(message)


engine = pyttsx3.init()
engine.setProperty('rate', 150)
engine.setProperty('volume', 1)

while True:
command = listen_command()
do_this_message(command)
👍6
#АнимацияБулевыхОперацийНаPython
Код из видео:

from manim import *


class Example(Scene):
def construct(self):
ellipse1 = Ellipse(width=4, height=5, fill_opacity=0.5, color=BLUE, stroke_width=10).move_to(LEFT)
ellipse2 = ellipse1.copy().set_color(color=RED).move_to(RIGHT)
bool_ops_text = MarkupText('<u>Example</u>').next_to(ellipse1, UP * 3)
ellipse_group = Group(bool_ops_text, ellipse1, ellipse2).move_to(LEFT * 3)
self.play(FadeIn(ellipse_group))

i = Intersection(ellipse1, ellipse2, color=GREEN, fill_opacity=0.5)
self.play(i.animate.scale(0.25).move_to(RIGHT * 5 + UP * 2.5))
intersaction_text = Text('Intersection', font_size=23).next_to(i, UP)
self.play(FadeIn(intersaction_text))

u = Union(ellipse1, ellipse2, color=ORANGE, fill_opacity=0.5)
union_text = Text('Union', font_size=23)
self.play(u.animate.scale(0.3).next_to(i, DOWN, buff=union_text.height * 3))
union_text.next_to(u, UP)
self.play(FadeIn(union_text))

e = Exclusion(ellipse1, ellipse2, color=YELLOW, fill_opacity=0.5)
exclusion_text = Text('Exclusion', font_size=23)
self.play(e.animate.scale(0.3).next_to(u, DOWN, buff=exclusion_text.height * 3.5))
exclusion_text.next_to(e, UP)
self.play(FadeIn(exclusion_text))

d = Difference(ellipse1, ellipse2, color=PINK, fill_opacity=0.5)
difference_text = Text('Difference', font_size=23)
self.play(d.animate.scale(0.3).next_to(u, LEFT, buff=difference_text.height * 3.5))
difference_text.next_to(d, UP)
self.play(FadeIn(difference_text))
#ПрячемФайлыВJpegИзображениеСПомощьюPython
Код из видео:

Прячем файл в изображение:
with open('photo.jpg', 'ab') as f, open('start.zip', 'rb') as s:
f.write(s.read())

Достаём канал:
with open('photo.jpg', 'rb') as f:
content = f.read()
offset = content.index(bytes.fromhex('FFD9'))

f.seek(offset + 2)
with open('newfile.zip', 'wb') as s:
s.write(f.read())
🎉2
#СъёмкаВидеоНаВебкамеруСПомощьюPython
Код из видео:

import cv2

cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FPS, 24)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)

codec = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', codec, 25.0, (1280, 720))

while True:
ret, frame = cap.read()
cv2.imshow('Web-camera', frame)
out.write(frame)

if cv2.waitKey(1) & 0xFF == ord('q'):
break

out.release()
cap.release()
cv2.destroyAllWindows()
👍2
#ДелаемКартинкуКнопкойВTkinterPython
Код из видео:

from tkinter import *
from PIL import ImageTk

root = Tk()
root.geometry('300x100')
root.resizable(False, False)
imgWatch = ImageTk.PhotoImage(file="watch.png")
btnWatch = Button(root, height=70, image=imgWatch, font='Arial 15 bold', compound=RIGHT, text='Часы')
btnWatch.pack()

root.mainloop()
👍8
#ПростаяВизуализацияДанныхНаКартеПоКоординатамСПомощьюPython
Код из видео:

import folium

m = folium.Map(location=[58.001645, 102.694781], zoom_start=12)

tooltip = ''
tooltip_2 = ''

folium.Marker([], popup='Усть-Илимск_', tooltip=tooltip).add_to(m)
folium.Marker([], popup='Братск_', tooltip=tooltip_2).add_to(m)
m.save('name.html')
👍3