-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcovid_tracking.py
59 lines (49 loc) · 1.97 KB
/
covid_tracking.py
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
def track(login):
global covid_symptoms, covid_points, list_of_people
print(f"{login}, please answer the following questions with either 'Y' for yes or 'N' for no.")
questions = {
"Have you had any fever recently?": 30,
"Do you find yourself with a runny nose?": 30,
"Do you find yourself often coughing?": 25,
"Have you identified a loss of smell or taste?": 35,
"Do you have a sore throat?": 15,
"Have you had any headaches?": 10,
"Have you had any muscle aches?": 30,
"Have you experienced any Diarrhea or abdominal cramps?": 10
}
for question, points in questions.items():
response = input(question + " : ")
if response == "Y":
covid_symptoms += 1
covid_points += points
list_of_people.setdefault(login, []).extend([covid_symptoms, covid_points])
write_to_file('covid_roster.txt', list_of_people)
covid_symptoms, covid_points = 0, 0 # Reset after logging
def write_to_file(filename, data):
with open(filename, 'w+') as file:
for key, value in data.items():
file.write(f"{key},{value}\n")
def tracking():
global list_of_people
while True:
try:
login = input("What is your name?: ")
if login in list_of_people:
password = input("What is your four-digit password?: ")
if password in list_of_people[login]:
track(login)
break
else:
print("Your password is incorrect. Try again or delete your account and sign in if you forgot!")
break
else:
print("Please sign up before logging in symptoms!")
break
except Exception as e:
print(f"An error occurred: {e}")
# Initialize global variables
covid_symptoms = 0
covid_points = 0
list_of_people = {} # This should be populated with user data
# Example usage
# tracking()