Python beginner projects from a Python beginner dev

douglascf

Douglas Fornaro

Posted on January 24, 2021

Python beginner projects from a Python beginner dev

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))
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
from youtube_dl import YoutubeDL

audio_downloader = YoutubeDL({'format':'bestaudio'})
audio_downloader.extract_info(input('Enter youtube url :  '))
Enter fullscreen mode Exit fullscreen mode

4. Message encrypt-decrypt

This project encrypts and decrypts a message.

Pre-requirement

It's needed to install the cryptography:

pip3 install cryptography
Enter fullscreen mode Exit fullscreen mode
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"))
Enter fullscreen mode Exit fullscreen mode
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"))
Enter fullscreen mode Exit fullscreen mode


Now it's your time to contribute, share others ideas that a Python beginner, including me, can get inspired to improve our skills!

💖 💪 🙅 🚩
douglascf
Douglas Fornaro

Posted on January 24, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Learning Python
javascript Learning Python

November 28, 2024

Calculate savings with Python!
beginners Calculate savings with Python!

November 26, 2024

UV the game-changer package manager
programming UV the game-changer package manager

November 24, 2024

Beginners Guide for Classes
python Beginners Guide for Classes

November 20, 2024