+

Building a Birthday Reminder Application in Python

In this section, we will see how to create a birthday reminder application using Python.

Problem Statement

Create an application using Python that can check if there is a birthday on the current day or not. If it is the birthday of any of the listed persons, send a notification to the System with the name of this person.

We need a file in which we can save the date and month, as well as the person`s name as a search file for this applications. The file will look like &


interface


< br>

Here we transform this application into a bootable application that starts at system startup.

Steps to create a birthday reminder application

  • Take the search file and read it.
  • Does the date and month match the current date and month
    • Send a notification with all names to the system, whose birthday is today.
  • Stop
  • Does the date and month match the current date and month
     importos, time #Take the birthday lookup file from home directory file_path = os.getenv (`HOME`) +` / birth_day_lookup.txt` defcheck_birthday (): lookup_file = open (file_path, `r`) #open the lookup file as read mode today = time.strftime (`% d-% B`) #get the todays date as dd-Month format bday_flag = 0 #loop through each entry in th e birthday file, and check whether the day is present or not for entry inlookup_file: if today in entry: line = entry.split (``) #cut the line on spaces to get name and surname bday_flag = 1 os.system (` notify-send "Today is` + line [1] + `` + line [2] + `` s Birthday "`) ifbday_flag == 0: os.system (`notify-send" No birthday for today is listed "` ) check_birthday () 
  • Send a notification to the system with all names whose birthday is today.
  • Output
  • Stop
 sudochmod + x file_name.py 
 sudocp file_name.py / usr / bin 

start commands



Get Solution for free from DataCamp guru