-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain miniLab.py
95 lines (72 loc) · 2.22 KB
/
Main miniLab.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
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
91
92
93
94
95
# -*- coding: utf-8 -*-
from engi1020.arduino import *
from time import sleep
def Probability (orderedList):
A = {'f': 0.769,
'c': 0.958,
'v': 0.575,
'd'}
B = ['v', 'd', 'c', 'f']
C = ['d', 'v', 'c', 'f']
if orderedList == A:
p = 0.769*0.958*0.575*1
print(f'The probability of you having covid is {p}')
sleep(10)
print('Please visit the closest doctor')
elif orderedList == B:
def checkdigitalInputs (pin1, pin2):
val = 0
if digital_read(pin1) == 1 and digital_read(pin2) == 0:
val = pin1
elif digital_read(pin1) == 0 and digital_read(pin2) == 1:
val = pin2
return val
Answer = ['No', 'Yes']
Questions = [f, c, v, d]
Answers = []
Order = [1, 2, 3, 4]
for q in Questions:
lcd_print(q)
while True:
if checkdigitalInputs(pin1, pin2) == pin1:
Answers.append(Answer[0])
break
elif checkdigitalInputs(pin1, pin2) == pin2:
Answers.append(Answer[1])
break
Total = {
'f' : Answers[0],
'c' : Answers[1],
'v' : Answers[2],
'd' : Answers[3],
}
for i in Total:
if Total[i] == 'No':
Total.pop(i)
Order = dict.fromkeys(Total.keys())
L = list(Order)
Number = {1: '1st',
2: '2nd',
3: '3rd',
4: '4th'}
#Order of the symptoms
for n in range(1, len(Total) + 1):
for i in L:
if Order[i] == None:
lcd_print(f' is {i} your {Number[n]} symptom ')
while True:
if checkdigitalInputs(pin1, pin2) == pin1:
break
elif checkdigitalInputs(pin1, pin2) == pin2:
Order.update({i : n})
break
if Order[i] == n:
break
sorted_values = sorted(Order.values())
sorted_Order = {}
for i in sorted_values:
for k in L:
if Order[k] == i:
sorted_Order[k] = Order[k]
break
Final_Order = list(dict.fromkeys(sorted_Order()))