Hey all,
So, I just started studying Python and I developed some beginner projects that I'd like to share. This way others Python beginner devs can get inspired from them!
1. Dices simulator
This project simulates and prints two random dices.
import random
dices = 2
for i in range(0, dices):
print(random.randint(1,6))
2. Password generator
This project generates a random 16-length password.
import random
lower = 'abcdefghijklmnopqrstuvwxyz'
upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
numbers = '0123456789'
symbols = '[]{}()*;/,_-!@#$%&+='
all = lower + upper + numbers + symbols
length = 16
password = ''.join(random.sample(all, length))
print(password)
3. Youtube audio downloader
This project downloads the audio from a YouTube URL.
Pre-requirement
It's needed to install the youtube_dl
:
pip3 install youtube-dl
from youtube_dl import YoutubeDL
audio_downloader = YoutubeDL({'format':'bestaudio'})
audio_downloader.extract_info(input('Enter youtube url : '))
4. Message encrypt-decrypt
This project encrypts and decrypts a message.
Pre-requirement
It's needed to install the cryptography
:
pip3 install cryptography
Encrypt a message
from cryptography.fernet import Fernet
key = b'ntLaRE-8-a81Bqa74aCL6ejFW4hr6ZO9m0fWbDOmys8=' # Some awesome key
message = input('Enter a message: ')
f = Fernet(key)
encrypted = f.encrypt(message.encode())
print(encrypted.decode("utf-8"))
Decrypt a message
from cryptography.fernet import Fernet
key = b'ntLaRE-8-a81Bqa74aCL6ejFW4hr6ZO9m0fWbDOmys8=' # Some awesome key
message = bytes(input('Enter a encrypted message: '), encoding='utf8')
f = Fernet(key)
decrypted = f.decrypt(message)
print(decrypted.decode("utf-8"))
Now it's your time to contribute, share others ideas that a Python beginner, including me, can get inspired to improve our skills!
Top comments (0)