Guest User

main study tracker.py

a guest
Feb 26th, 2026
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.31 KB | None | 0 0
  1. def Add_subject():
  2.     try:
  3.         subject = input("Which subject do you want to add:")
  4.         with open("subjects.txt","a") as file:
  5.             file.write(subject +  "\n")
  6.            
  7.         with open("subjects.txt","r") as file:
  8.             subjects = file.read()
  9.            
  10.         print("Subject added successfully")
  11.        
  12.     except Exception as e:
  13.         print("Error",e)
  14.        
  15. def Remove_subject():
  16.     try:
  17.         with open("subjects.txt","r") as file:
  18.             subjects = file.read().splitlines()
  19.            
  20.         for i, subject in enumerate(subjects, start=1):
  21.             print(f"{i}:{subject}")
  22.            
  23.         remove = int(input("Which subject to remove(1/2/3, etc):"))
  24.         index = remove - 1
  25.        
  26.         if remove > len(subjects):
  27.             print("Subject does not exist")
  28.         else:
  29.             subjects.pop(index)
  30.        
  31.             with open("subjects.txt","w") as file:
  32.                 for s in subjects:
  33.                     file.write(s + "\n")
  34.                
  35.     except Exception as e:
  36.         print("Error:",e)
  37.  
  38. def View():
  39.     try:
  40.         with open("subjects.txt","r") as file:
  41.             subjects = file.read().splitlines()  
  42.                      
  43.         for i,subject in enumerate(subjects,start=1):
  44.             print(f"{i}.{subject}")
  45.    
  46.     except Exception as e:
  47.         print("Error:",e)    
  48.        
  49. def Chapters():
  50.     try:
  51.         with open("subjects.txt","r") as file:
  52.             subjects = file.read().splitlines()
  53.            
  54.         for i, subject in enumerate(subjects, start=1):
  55.             print(f"{i}:{subject}")
  56.            
  57.         add = int(input("Which subject to add chapters to(1/2/3, etc):"))
  58.        
  59.         if add > len(subjects):
  60.             print("Subject does not exist")
  61.  
  62. while True:
  63.     print("\nStudy Tracker\nWhat operation do you want to do?\n\n1.Add subject\n2.Remove subject\n3.View subjects\n4.Add/remove chapters\n5.Add/remove notes for subjects\n6.View chapters and notes\n7.log study sessions\n8.View progress\n9.Calculator(for math)\n")
  64.    
  65.     choice = input("Enter your choice:")
  66.     if choice not in ["1","2","3","4","5","6","7"]:
  67.         print("Enter a valid choice")
  68.         continue
  69.    
  70.     if choice == "1":
  71.         Add_subject()
  72.    
  73.     elif choice == "2":
  74.         Remove_subject()
  75.    
  76.     elif choice == "3":
  77.         View()
  78.        
Advertisement
Add Comment
Please, Sign In to add comment