-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudy_tracker.py
More file actions
90 lines (78 loc) · 3.09 KB
/
Copy pathstudy_tracker.py
File metadata and controls
90 lines (78 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
study_times = {}
def add_session():
while True:
subject_ask = input("Enter the subject name: ").capitalize()
if subject_ask.strip().isdigit():
print("⚠️ Warning: You entered a number only. Please enter a valid subject name.")
else:
break
while True:
time_ask = input("Enter study time of that subject: ")
if time_ask.isdigit():
time_ask = int(time_ask)
break
else:
print("⚠️ Please enter time in numbers.")
with open ("study.txt", "a") as p:
p.write(f"{subject_ask} : {time_ask} Hours\n")
print(f"✅ Session saved, {subject_ask} : {time_ask} Hours")
def view_summary():
with open("study.txt", "r") as f:
content = f.read()
print("--- Study Summary ---")
print(content)
print("~~~~~~~~~~~~~~~~~~")
def most_studied_and_total_time():
with open("study.txt", "r") as file:
for line in file:
parts = line.split(":")
subject = parts[0].strip()
hours = int(''.join([x for x in parts[1] if x.isdigit()]))
if subject in study_times:
study_times[subject] += hours
else:
study_times[subject] = hours
max_studied = max(study_times, key=study_times.get)
total_time = sum(study_times.values())
print(f"Your most studied subject is {max_studied}")
print(f"Your total study time is {total_time} Hours")
def reset():
with open("p.txt", "w") as f:
pass
functions = ["1. Add sessions", "2. View study summary", "3. View most studied subject and total time", "4. Reset tracker"]
print("=" * 80)
print("Welcome to Study Tracker - By PranavGPT")
print("=" * 80)
print("Functions you can perfom(before further updates) are:")
for i in functions:
print(i)
print("=" * 80)
while True:
try:
option = int(input("Enter which functions do you want to perform(Enter 1 - 4): "))
except ValueError:
print("⚠️ Please enter a number between 1 and 4.")
continue
if option not in [1, 2, 3, 4]:
print("⚠️ Please enter a valid option (1-4).")
continue
if option == 1:
print("Let add some study sessions...")
add_session()
elif option == 2:
view_summary()
elif option == 3:
most_studied_and_total_time()
elif option == 4:
reset()
print("✅ Tracker reset succesfull.")
again = input("Do you want to perform any other functions(Yes / No): ")
if again == "no":
print("=" * 80)
print("🙏 Thanks a lot for using our services")
feed = input("Do you want to provide a feedback(Yes / No): ")
if feed == "yes":
feedback = input("Provide your feedback: ")
print("Your support and feedback will give me motivation for upgrading this app in future times..🙏")
print("=" * 80)
break