Open In App

Personalized Task Manager in Python

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to create a task management software in Python. This software is going to be very useful for those who don’t want to burden themselves with which task they have done and which they are left with. Being a coder we have to keep in mind which competition is going on, which courses we are enrolled with, and which YouTube playlist are we following, and so on. This software is going to keep account of all such details in a secured manner so that only you have the access to your data.

Tools and Technologies Used in the Project:

  • This project is going to be very beginner-friendly.
  • The working of this software is entirely POP( Procedural Oriented Programming). Basic knowledge about python functions is needed.
  • Datetime module of python.

Required Skill set to Build the Project:

  • Python
  • Visual Studio Code or any other code editor.

Step-by-step Implementation:

Follow the below steps to implement a personalized task manager using Python:

  • Step 1: Create a folder name ‘Task Manager’. Open it in your favorite code editor.
  • Step 2: Create a python file with the name ‘task_manager.py’.
  • Step 3: Now we are ready to code our software. Initially, we will start by creating our sign-up function. The signup function will be taking the username by which the user is going to make his/her account and ask to set a password for that account. The below code will make things clear.

Python3




def signup():
    print("Please enter the username by which you \
    wanna access your account")
    username = input("please enter here:  ")
    password = input("Enter a password:  ")


  • Step 4: Now we will create a ‘user_information’ function which will take the data from the ‘signup’ function and make a text file to save the user data. The below code will show how things will proceed.

Python3




# pssd means password, ussnm is username
def user_information(ussnm, pssd):
    name = input("enter your name please: ")
    address = input("your address")
    age = input("Your age please")
    ussnm_ = ussnm+" task.txt"
     
    f = open(ussnm_, 'a')
    f.write(pssd)
    f.write("\nName: ")
    f.write(name)
    f.write('\n')
    f.write("Address :")
 
    f.write(address)
    f.write('\n')
    f.write("Age :")
    f.write(age)
    f.write('\n')
    f.close()
 
 
def signup():
    print("Please enter the username by which you\
    wanna access your account")
    username = input("please enter here:  ")
    password = input("Enter a password:  ")
    user_information(username, password)


  • Step 5: Once the text file is created by the user_information function, it’s time that we code our log-in function. The log-in function will take the username and ask for the password connected to it. Once the user enters the password the function will check if the password saved in the text file is the same as that entered. The code can explain more precisely,

Python3




def login():
    print("Please enter your username ")
    user_nm = input("Enter here: ")
     
    # Password as entered while logging in
    pssd_wr = (input("enterr the password"))+'\n'
    try:
        usernm = user_nm+" task.txt"
        f_ = open(usernm, 'r')
         
        # variable 'k' contains the password as saved
        # in the file
        k = f_.readlines(0)[0]
        f_.close()
         
         # Checking if the Password entered is same as
         # the password saved while signing in
        if pssd_wr == k:
            print(
                "1--to view your data \n2--To add task \n3--Update\
                task status \n4--View task status")
            a = input()
        else:
            print("SIR YOUR PASSWORD OR USERNAME IS WRONG , Plz enter Again")
            login()
    except Exception as e:
        print(e)
        login()


  • Step 6: In this step, we will make sure that after the user signs in we can ask him/her to log in to their account. This can be done by calling the log-in function at the end of the sign-in function. Hence, the sign-in function will look like

Python3




def signup():
    print("Please enter the username by which you wanna access your account")
    username = input("please enter here:  ")
    password = input("Enter a password:  ")
    user_information(username, password)
    print("Sir please proceed towards log in")
    login()


  • Step 7: Let’s complete the four important functions as mentioned in the ‘login ‘block. Namely, function to view data, function to add a task to the data, function to update task status, and function to view task status. In this step, we are going to complete the ‘login’ function by completing the if-else part after taking input of the user’s demand, i.e the input to the variable a. Refer to the code below:

Python3




def login():
    print("Please enter your username ")
    user_nm = input("Enter here: ")
     
    # Password as entered while logging in
    pssd_wr = (input("enterr the password"))+'\n'
    try:
        usernm = user_nm+" task.txt"
        f_ = open(usernm, 'r')
         
        # variable 'k' contains the password as
        # saved in the file
        k = f_.readlines(0)[0]
        f_.close()
         
         # Checking if the Password entered is same
         # as the password saved while signing in
        if pssd_wr == k:
            print(
                "1--to view your data \n2--To add task \n3--Update\
                task \n4--VIEW TASK STATUS")
            a = input()
             
            if a == '1':
                view_data(usernm)
            elif a == '2':
                # add task
                task_information(usernm)
            elif a == '3':
                task_update(user_nm)
            elif a == '4':
                task_update_viewer(user_nm)
            else:
                print("Wrong input ! ")
        else:
            print("SIR YOUR PASSWORD OR USERNAME IS WRONG")
            login()
 
    except Exception as e:
        print(e)
        login()
 
 
def view_data(username):
    pass
 
def task_information(username):
    pass
 
def task_update(username):
    pass
 
def task_update_viewer(username):
    pass


 
 

As you can see, the pass command is used to let us write the function name and argument without the function body and also prevent the error message from it in the code editor. 

  • Step 8: Let’s code the view data block.

Python3




def view_data(username):
    ff = open(username, 'r')
    print(ff.read())
    ff.close()


  • Step 9: To code the task information block we need to keep in mind the basic concepts of text handling in python. We will ask the user how many tasks he/she wants to add and as per his wish we will iterate a loop for that many times and ask him to enter his task and the target by which he wants to finish the task.

Python3




def task_information(username):
    print("Sir enter n.o of task you want to ADD")
    j = int(input())
    f1 = open(username, 'a')
     
    for i in range(1, j+1):
        task = input("enter the task")
        target = input("enter the target")
        pp = "TASK "+str(i)+' :'
        qq = "TARGET "+str(i)+" :"
         
        f1.write(pp)
        f1.write(task)
        f1.write('\n')
        f1.write(qq)
        f1.write(target)
        f1.write('\n')
         
        print("Do u want to stop press space bar otherwise enter")
        s = input()
        if s == ' ':
            break
    f1.close()


Do notice that we have added a message that if the user wants to stop adding a task before the number of times he wished to, then he will get a chance. This makes the program very much user-friendly.

  • Step 10: Updating the task status goes in the similar concept of text handling in python. What we will be doing is, we will save which task number is completed, which is ongoing, and which is not yet started with a date time stamp with them. That part of the text file will look like,
2021-06-01 14:44:02.851506
COMPLETED TASK  
1,3,4
ONGOING TASK  
2
NOT YET STARTED
5

Python3




def task_update(username):
    username = username+" TASK.txt"
    print("Please enter the tasks which are completed ")
     
    task_completed = input()
    print("Enter task which are still not started by you")
     
    task_not_started = input()
    print("Enter task which you are doing")
     
    task_ongoing = input()
    fw = open(username, 'a')
    DT = str(datetime.datetime.now())
     
    fw.write(DT)
    fw.write("\n")
    fw.write("COMPLETED TASK \n")
    fw.write(task_completed)
    fw.write("\n")
    fw.write("ONGOING TASK \n")
    fw.write(task_ongoing)
    fw.write("\n")
    fw.write("NOT YET STARTED\n")
    fw.write(task_not_started)
    fw.write("\n")


  • Step 11: Now we are left with the task update viewer function. This function is as simple as the ‘view_data’ function.

Python3




def task_update_viewer(username):
    ussnm = username+" TASK.txt"
    o = open(ussnm, 'r')
    print(o.read())
    o.close()


This puts to the end of the program. But before we end the most important task which is still left is coding the main function and controlling the flow of command of the program from the main function itself.

  • Step 12: The main function.

Python3




if __name__ == '__main__':
    print("WELCOME TO ANURAG`S TASK MANAGER")
    print("sir are you new to this software")
    a = int(input("Type 1 if new otherwise press 0 ::"))
     
    if a == 1:
        signup()
    elif a == 0:
        login()
    else:
        print("You have provided wrong input !")


This marks the end of the code. You should try to do suitable changes to this code so that the software becomes more beautiful.

Source Code:

Python3




import datetime
 
# pssd means password, ussnm is username
def user_information(ussnm, pssd): 
    name = input("enter your name please: ")
    address = input("your address")
    age = input("Your age please")
    ussnm_ = ussnm+" task.txt"
    f = open(ussnm_, 'a')
    f.write(pssd)
    f.write("\nName: ")
    f.write(name)
    f.write('\n')
    f.write("Address :")
 
    f.write(address)
    f.write('\n')
    f.write("Age :")
    f.write(age)
    f.write('\n')
    f.close()
 
 
def signup():
    print("Please enter the username by which you wanna access your account")
    username = input("please enter here:  ")
    password = input("Enter a password:  ")
    user_information(username, password)
    print("Sir please proceed towards log in")
    login()
 
 
def login():
    print("Please enter your username ")
    user_nm = input("Enter here: ")
     
    # Password as entered while logging in
    pssd_wr = (input("enterr the password"))+'\n'
    try:
        usernm = user_nm+" task.txt"
        f_ = open(usernm, 'r')
         
        # variable 'k' contains the password as saved
        # in the file
        k = f_.readlines(0)[0]
        f_.close()
         
        # Checking if the Password entered is same as
        # the password saved while signing in
        if pssd_wr == k:  
            print(
                "1--to view your data \n2--To add task \n3--Update\
                task \n4--VIEW TASK STATUS")
            a = input()
             
            if a == '1':
                view_data(usernm)
            elif a == '2':
                # add task
                task_information(usernm)
            elif a == '3':
                task_update(user_nm)
            elif a == '4':
                task_update_viewer(user_nm)
            else:
                print("Wrong input ! bhai dekh kr input dal")
        else:
            print("SIR YOUR PASSWORD OR USERNAME IS WRONG")
            login()
 
    except Exception as e:
        print(e)
        login()
 
 
def view_data(username):
    ff = open(username, 'r')
    print(ff.read())
    ff.close()
 
 
def task_information(username):
    print("Sir enter n.o of task you want to ADD")
    j = int(input())
    f1 = open(username, 'a')
     
    for i in range(1, j+1):
        task = input("enter the task")
        target = input("enter the target")
        pp = "TASK "+str(i)+' :'
        qq = "TARGET "+str(i)+" :"
         
        f1.write(pp)
        f1.write(task)
        f1.write('\n')
        f1.write(qq)
        f1.write(target)
        f1.write('\n')
        print("Do u want to stop press space bar otherwise enter")
        s = input()
        if s == ' ':
            break
    f1.close()
 
 
def task_update(username):
    username = username+" TASK.txt"
    print("Please enter the tasks which are completed ")
    task_completed = input()
     
    print("Enter task which are still not started by you")
    task_not_started = input()
     
    print("Enter task which you are doing")
    task_ongoing = input()
     
    fw = open(username, 'a')
    DT = str(datetime.datetime.now())
    fw.write(DT)
    fw.write("\n")
    fw.write("COMPLETED TASK \n")
    fw.write(task_completed)
    fw.write("\n")
    fw.write("ONGOING TASK \n")
    fw.write(task_ongoing)
    fw.write("\n")
    fw.write("NOT YET STARTED\n")
    fw.write(task_not_started)
    fw.write("\n")
 
 
def task_update_viewer(username):
    ussnm = username+" TASK.txt"
    o = open(ussnm, 'r')
    print(o.read())
    o.close()
 
 
if __name__ == '__main__':
    print("WELCOME TO ANURAG`S TASK MANAGER")
    print("sir are you new to this software")
    a = int(input("Type 1 if new otherwise press 0 ::"))
    if a == 1:
        signup()
    elif a == 0:
        login()
    else:
        print("You have provided wrong input !")


Output:

 Look how the sign-in part appears to the user:

A logged-in user will operate this software as :

Project Application in Real-Life

  • This is very helpful for a student to keep account of his task or homework and its deadline of completion.
  • This is very helpful for learners to keep account of what to learn and the resource.


Last Updated : 05 Apr, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads