· 6 years ago · May 23, 2019, 05:20 PM
1def main_program():
2 while True:
3 try:
4 age = float(input("Please input your age: "))
5 except ValueError:
6 print("ERROR")
7 else:
8 if age < 20 and age > 0:
9 dose = age * 0.1
10 while True:
11 try:
12 gender = input("Please input your gender(Male or Female): ")
13 except ValueError:
14 print("ERROR")
15 else:
16 if gender == "Female":
17 prengan = input("Are you pregnant(Yes or No)?: ")
18 if prengan == "Yes" and dose > 1.5:
19 print("Your dose is: ", 1.5)
20 quit()
21 elif prengan == "No" or prengan == "Yes" and dose <= 1.5:
22 print("Your dose is: ", dose)
23 quit()
24 else:
25 print("ERROR")
26 elif gender == "Male":
27 dose = dose / 2
28 print("Your dose is: ", dose)
29 quit()
30 else:
31 print("ERROR")
32 elif age >= 20:
33 dose = 2
34 while True:
35 try:
36 gender = input("Please input your gender(Male or Female): ")
37 except ValueError:
38 print("ERROR")
39 else:
40 if gender == "Female":
41 while True:
42 try:
43 prengan = input("Are you pregnant(Yes or No)?: ")
44 except ValueError:
45 print("ERROR")
46 else:
47 if prengan == "Yes" and dose > 1.5:
48 print("Your dose is: ", 1.5)
49 quit()
50 elif prengan == "Yes" and dose <= 1.5:
51 print("Your dose is: ", dose)
52 quit()
53 elif prengan == "No":
54 print("Your dose is: ", dose)
55 quit()
56 elif gender == "Male":
57 dose = dose / 2
58 print("Your dose is: ", dose)
59 quit()
60 else:
61 print("ERROR")
62 else:
63 print("ERROR")
64
65def account_creation():
66 import sqlite3
67
68 username_maker = input("What would you like your username to be?: ")
69 password_maker = input("What would you like your password to be?: ")
70
71 db = sqlite3.connect('AccountDetails.db')
72 cursor = db.cursor()
73
74 cursor.execute('''CREATE TABLE IF NOT EXISTS details_acc(
75 usernames TEXT PRIMARY KEY,
76 passwords TEXT NOT NULL,
77 )''')
78
79 cursor.execute('''INSERT INTO details_acc(usernames, passwords)
80 VALUES(username_maker, password_maker)''')
81
82 db.commit()
83
84 for record in cursor():
85 print(record, "These are your account details.")
86
87 db.close()
88
89 try:
90 ask1 = input("Would you like to access the dose calculator and login right now(Yes or No)?: ")
91 while True:
92 if ask1 == "Yes":
93 account_input()
94 elif ask1 == "No":
95 ask2 == input("
96 else:
97 print("ERROR")
98
99def account_input():
100 import sqlite3
101
102 db = sqlite3.connect('AccountDetails.db')
103 cursor = db.cursor()
104
105 usermaker = cursor.execute('''SELECT usernames FROM details_acc''')
106 passinpt = cursor.execute('''SELECT passwords FROM details_acc''')
107
108 db.close()
109
110 username_inpt = input("What is your username?: ")
111 password_inpt = input("What is your password?: ")
112 while True:
113 if username_inpt == usermaker and passinpt == password_maker:
114 main_program()
115 else:
116 print("ERROR: Please try again.")
117
118def menu_one():
119 fod = False
120
121 try:
122 menu_options = int(input("You have 3 options: \n Option 1: Create an account(Note: If your account has been created once, you can't create a new one nor delete your old one or edit it). \n Option 2: Login into your account and access the dose calculator. \n Option 3: To quit the program. "))
123 except ValueError:
124 print("ERROR")
125 else:
126 while True:
127 if menu_options == 1:
128 if
129
130 account_creation()
131 elif menu_options == 2:
132 account_input()
133 elif menu_options == 3:
134 quit()
135 else:
136 print("ERROR")