1. Download Youtube Video
from pytube import YouTube
link = input("Enter the URL of the YouTube video")
video = YouTube(link)
stream = video.streams.get_highest_resolution()
stream.download()
Note :- This will automatically download Youtube, when you enter the URL of the video.
2. Generate Beep sound
import winsound
f = 3599 #Frequency
d = 5000 #Duration
winsound.Beep(f,d)
Note :- This will throw some beep sound, when you run this code. It can be changed by Frequency and Duration..
3. Amazing Colored Design
import turtle
colors = ['orange', 'red', 'pink', 'yellow', 'blue', 'green']
screen = turtle.Screen()
trtl=turtle.Turtle()
trtl.speed(0)
screen.bgcolor('black')
for x in range(360):
trtl.pencolor(colors[x % 6])
trtl.width(x/5+1)
trtl.forward(x)
trtl.left(20)
Note :- This will print amazing circle design with colors.
4. Auto Typing code in PY
import pyautogui as sak
# sak.typewrite("PythonCoder")
sak.typewrite("Hello Anonymous!", interval = 0.30)
H E L L O A N O N Y M O U S
Note :- This will automatically type code in further line, not in compiling area!
5. Random Password Generator
import random
import string
LETTERS = string.ascii_letters
NUMS = '0123456789'
SPE = '-+*%&$!_'
SYMBOLS = LETTERS + NUMS + SPE
len = int(input("ENTER PASS.LENGTH:"))
password = "".join(random.sample(SYMBOLS,len))
print(password)
Output :-
ENTER PASS.LENGTH: 8
mev67iGO
Note :- This Password generator randomly so, this result will be changed whenever you applied this code.
6. Generate a Random Number
import random
min = 1
max = 300000000000
ran = random.randint(min,max)
print(ran)
Output :-
52488484588
Note :- This number generate randomly, so the result will be different compiler area.
7. Copy & Paste Using PY
import pyperclip as p
text = "Hello, Anonymous!"
p.copy(text)
s=p.paste()
print(s)
Output :-
Hello, Anonymous!
8. Check IP Address
import socket as s
hostn = s.gethostname()
IP = s.gethostbyname(hostn)
print("IP ADDRESS IS"+ IP)
Output :-
IP ADDRESS IS192.168.0.103
9. Live IPL Cricket score
import sports
from pynotifier import Notification
matchinfo = sports.get_sport("CRICKET")
Notification(title="LIVE SCORE",description=str(matchinfo),duration=40).send()
Note :- This will print the live score of IPL. If you want to try this, use when IPL is running.
10. Different ways to get DateTime
1. Today's date
from datetime import date
today = date.today()
print("Today's date:",today)
Output :-
Today's date: 2021-04-24
2. DateTime Attributes
import datetime
now = datetime.datetime.now()
print(now.day)
print(now.hour)
print(now.year)
Output :-
24
04
2021
3. Get Month
import datetime
dt = datetime.datetime(2020,6,29)
print(dt.strftime('%B'))
Output :-
June
4. Custom Datetime
import datetime
dt = datetime.datetime(2020,6,29)
print(dt)
Output :-
2020-06-29 00:00:00
5. Get Today's day
import datetime
x = datetime.datetime.now()
print(x.year)
print(x.strftime("%A"))
Output :-
2021
Saturday
0 Comments