DEV Community

Cover image for Build a simple Reminder App in Python ⏰
andrewu
andrewu

Posted on

Build a simple Reminder App in Python ⏰

I keep forgetting to take breaks while working on my laptop, so I've decided to make a reminder app. I'm new to Python, so it will work in command-prompt mode. Yep, no graphical interface for now, but I might add it later. Here we go ✨

The app will be super simple:

  1. Ask yourself what you wanna be reminded about
  2. Ask in what amount of time (in minutes)
  3. Calculate timeout
  4. Wait for the specified time
  5. Send a reminder from step 1

Alt Text

Step 0: Setting things up

Here is a Python command that I'll use:

import time

Import tells Python to load a module with the tools that we'll need for this. Time is the name of the module. We’ll only need a method called ‘sleep’ from that module. I'll use it to pause the program for a certain amount of time.

Step 1: Asking for a reminder

First you need to ask a user (in this case, yourself 🙃) and get a response. In a perfect world, we’d want a code like this:

reminder = user.ask("What shall I remind you about?")

But let's start with a simple implementation, so I’ll go with some built-in commands:

print("What shall I remind you about?")

print sends out a text message into Python’s default output (which in our case is command line).

text = str(input())

This means: ‘Take whatever the user has written, think of it as text, and put it into memory under the name “text”.’ Input() reads whatever the user inputs. Str() turns this into text. Equals means “put one thing into memory with such name.”

Step 2: Asking for time

Since we're building a reminder for work, let's calculate time in minutes:

print("In how many minutes?")

local_time = float(input())

The second line means ‘Take whatever the user typed, think of it as a number, put it in memory under the name “local_time”.

Alt Text

Step 3. Calculating timeout

We have a number of minutes that our app needs to wait before reminding us. But Python’s time.sleep() method requires seconds, not minutes. So we need to convert minutes into seconds:

local_time = local_time * 60

This reads: ‘take whatever is in memory under the name “local_time”, multiply it by 60, and put it in memory under the name “local_time”’.

Step 4. Waiting...

Now we’ll need that time module that we loaded in step 0:

time.sleep(local_time)

This reads: ‘Take the method “sleep.” from the “time” module. Find a piece of data under the name “local_time.” from the memory. Give that piece of data to “sleep” and see what happens.”

What happens is: we have a number of seconds in ‘local_time’. We give that number to ‘Sleep,’ and the program dozes off for the specified number of seconds.

Step 5. Sending a reminder

Remember that the reminder text is stored in memory under the name ‘text’? It’s time to use it:

print(text)

This means: take whatever is in the memory under ‘text’ and send it to output.

Alt Text

Final code

import time
print("What shall I remind you about?")
text = str(input())
print("In how many minutes?")
local_time = float(input())
local_time = local_time * 60
time.sleep(local_time)
print(text)

If you input this into your Jupyter notebook and run (Shift + Enter), you’ll see your program in action:

Alt Text

That's it for now, but I might add the graphical interface to it later. Would love to hear your comments on this!

Meanwhile, if you're bored and want to learn Python through building practical things, check out our course at Practicum. It has 20 hours of free lessons 🚀

Top comments (0)