cft

5 Python Projects That Can Be Built Under 5 Minutes

Learn to Build 5 Beginner-Friendly Python Projects With This Step-by-Step Guide.


user

Sai Ashish Konchada

3 years ago | 5 min read

Welcome to the Python Projects for Beginners Series. I'm Sai Ashish, technical blogger at The Insightful Coder, and today we are going to code 5 Python Projects that can be built in under 5 minutes. I hope you're psyched because this is going to be amazing πŸ’―

What Are We Going to Build?

1. Notification Generator πŸ”’

2. Check Your Battery Percentage πŸ”‹

3. Take a Screenshot πŸ–Ό

4. Figlet Generator πŸ” 

5. ConvertText to Speech πŸ—£

What Are We Going to Learn Today?

1. How to effectively use modules in our python programs

2. Basics of Python: Functions

Project 1: Notification Generator πŸ”’

As the name suggests, a notification generator generates a notification(a message) about a particular task, reminder or anything you require. In today's build, we would be generating a pop-up notification on a Windows device.

Apart from the obvious, you can integrate this snippet of code into any of your applications. For example, in How to Build an Alarm Clock using Python, you can also generate a notification along with your favourite song. Or suppose you wanted to get an alert whenever your battery percentage is below 35 or get reminders, this is the tool for you.

Let's Have a Look at Our Build:

Module Used:

For this build, we require the win10toast module. win10toast is an easy-to-use Python library for displaying Windows 10 Toast(Pop-up) Notifications. The official document of the module can be accessed from here.

To install the win10toast module, go to the terminal and run,

pip install win10toast

That's it. You're all ready for the build now.

Time to Code!

The first step is to import the win10toast module into our programming environment. For this, we use the import statement as,

from win10toast import ToastNotifier

Next, we define a function named windows_popup that takes three parameters as input β€” title, content and duration.

def windows_popup(title,content,duration=10):

Functions help break our program into smaller and modular chunks. Moreover, it avoids repetition and makes the code reusable. In our function, we code two statements,

toast=ToastNotifier()
toast.show_toast(title,content,duration=duration)

We create an instance of the ToastNotifier class and store it inside the toast variable. Imagine the instance as a remote control to your program. You can now use any buttons on the remote control to perform the task needed.

We call the show_toast function and pass the input parameters as seen.

Parameters:

  • title: the title of the notification. it appears in bold. Example: Reminder
  • content: the content of the notification. Example: Close down your desktop and go for a walk!
  • duration: the duration in seconds you want the notification to be shown on the screen

Finally, we call the function as:

windows_popup("Reminder", "Go and get a life!")

The Final Source Code for Notification Generator is seen below:

Final Source Code For Notification Generator Using Python
Final Source Code For Notification Generator Using Python

You can directly download the source code for Notification Generator from my Github Repository.

Project 2: Check Your Battery Percentage πŸ”‹

In this build, we generate the battery percentage of our device.

Module Used:

For this build, we use the psutil module. psutil is a cross-platform library for process and system monitoring in Python. The official documentation of the psutil module can be found here.

To install psutil into our system, type in the terminal the following:

pip install psutil

Time to Code!

As always, import the psutil module into our environment.

import psutil

Gain the remote control by creating an instance of the sensors_battery() class in the psutil module.

battery = psutil.sensors_battery()

Gain the battery percentage information into variable percent as follows:

percent = str(battery.percent)

To display the battery per cent on the screen, type:

print("Battery Percent= " + percent + "%")

Final Source Code for Battery Percentage Checker:

Final Source Code for Battery Percentage Checker Using Python
Final Source Code for Battery Percentage Checker Using Python

You can directly download the Battery Percentage Checker code from my Github Repository too.

To test your coding skills, try generating a notification when the battery percentage falls below 35%. Comment your code in the comment box below!

Project 3: Take a Screenshot πŸ–Ό

Modules Required:

For this build, we require the Pyautogui and the time module.

PyAutoGUI is a python module that lets you control your mouse and keyboard using a program. PyAutoGUI also lets you automate your everyday tasks and can play games, login into emails, and more. You can access the official documentation of Pyautogui module from here.

To install PyAutoGUI in your system, open your terminal and run:

pip install pyautogui

The time module provides various time-related functions. We use it to retrieve the system time and display it on the screen. You can access the official documentation from here.

Time to Code!

Importing the required modules into our python environment:

import pyautogui
import time

We use the time.sleep method to switch the application from our python environment to the screen we want to take a screenshot from.

time.sleep(3)

To take the screenshot, we use pyautogui's screenshot method and store it inside the img variable.

img = pyautogui.screenshot()

To save the image, we use the save method as:

img.save(r"image.png")

Note: This command will save the image into the same directory as the location of the python file you're running from.

Final Source Code for Screenshot Taker is as follows:

Final Source Code for Screenshot Taker Using Python
Final Source Code for Screenshot Taker Using Python

You can directly download the source code of the Screenshot Taker build from here.

Project 4: Figlet Generator πŸ” 

The Figlet Generator Converts ordinary text into a creative figure letter design(ASCII Art Font) as shown below:

Modules Required:

For this build, we require the PyFiglet module. You can access the official documentation of Pyfiglet module from here. The PyFiglet module can be installed by using:

pip install pyfiglet

Time to Code!

The first step is to import the Pyfiglet module.

import pyfiglet

To convert your word into ASCII Block Art format we use the figlet_format function. We store the result into a variable called result. For slant font, we set the font to slant. For a normal block, just omit that parameter and enter only the text in double-quotes.

result = pyfiglet.figlet_format("Sai Ashish", font = "slant")

Display your creativity using the print statement:

print(result)

Final Source Code for Figlet Generator:

Final Source Code for Figlet Generator Using Python
Final Source Code for Figlet Generator Using Python

You can directly download the source code from my Github Repository.

Project 5: Convert Text to Speech πŸ—£

Last but not the last and my most favourite build among all, the Text to Speech Generator.

Module Required:

For this amazing build, we require the pyttsx3 module. pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline and is compatible with both Python 2 and 3.You can check the official documentation from here.

To install pyttsx3 into our system, go to the terminal and type:

pip install pyttsx3

Time to Code!

We import the pyttsx3 module into our environment using:

import pyttsx3

To get the remote control, we initialise pyttsx3 as:

engine = pyttsx3.init()

After gaining the instance, we use the say method to tell the engine to speak the sentence provided to it.

engine.say("Hello Everyone")

Finally, we use the runAndWait command to run the command.

engine.runAndWait()

Final Source Code for Converting Text to Speech:

Final Source Code for Converting Text to Speech Using Python
Final Source Code for Converting Text to Speech Using Python

You can directly download the Text to Speech Build from my Github Repository.

That's it, folks! We have successfully learnt 5 short yet interesting builds that can be implemented in under 5 minutes. These builds are a very good stepping step for any beginner in Python.

Bonus Insights by The Insightful Coder:

  • Want to build more Python Beginner Friendly Projects? Visit the Python For Beginners Series 🐍
  • Interested in Building Your Own Artificial Intelligence Projects using Python?: Check out the Python AI Series🧠
  • I'm also dropping daily value bombs and development insights on my Instagram & Twitter HandleπŸ’―
  • Find and Download All My Project Source Codes at My Github Repository🎁

Upvote


user
Created by

Sai Ashish Konchada

I am a Full Stack Developer with industry experience building websites and web applications. I specialize in Java and have professional experience working with Angular and Springboot. I also have experience working in Artificial Intelligence and the Internet of Things. I have spent the last 2 years building, empowering communities, sharing my knowledge, advancing my skills, career, and network at Google Developer Students Club, The Insightful Coder, and as the Technical Head at SLRTCE. Take a look at my work or get in touch! https://theinsightfulcoder.com/


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles