-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab-operators.py
161 lines (141 loc) · 6.43 KB
/
lab-operators.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
isWeekend = True
print("Is weekend =", isWeekend)
temperature = 25
print("Temperature =", temperature)
toDoList = ''
print("To do list =", toDoList)
isHappy = isWeekend and temperature >= 20 and toDoList == ''
print("Is happy =", isHappy)
isHappy = not isWeekend and temperature < 20 and toDoList != ''
print("Is happy =", isHappy)
isHappy = isWeekend and temperature >= 20 and toDoList =='' or not isWeekend and temperature < 20 and toDoList != ''
print("Is happy =", isHappy)
isHappy - isWeekend and temperature >= 20 and toDoList == '' or not isWeekend and not (temperature >= 20 or toDoList == '')
print("Is happy =", isHappy)
'''
exercises
'''
# Zostajesz zatrudniony(a) do stworzenia oprogramowania pokładowego nowoczesnego samochodu.
# Aktualnie Twoim zadaniem jest oprogramowanie sterownika odpowiedzialnego za automatyczne włączanie świateł
# mijania w samochodzie. Będziesz pracować z następującymi zmiennymi:
#
# isAutomaticMode - zmienna logiczna, o następującym znaczeniu: wartość True oznacza, że kierowca ustawił
# pokrętło sterujące światłem na tryb automatyczny. Sterownik ma podejmować decyzję o zapaleniu świateł tylko
# jeżeli wartość tej zmiennej to True, ale zapalenie świateł zależy jeszcze od kolejnych warunków,
#
# is80PercentLight - zmienna logiczna o następującym znaczeniu: wartość True oznacza, że "chyba" mamy dzień,
# bo jest dość dużo światła. Światła w samochodzie powinny być zgaszone o ile nie ma innych warunków, które
# wpływałyby na to, że światła mają się świecić. Jeśli wartość zmiennej to False, tzn. że jest dość ciemno i światła
# powinny się zaświecić, oczywiście o ile jesteśmy w trybie automatycznym
#
# isDirectLight - zmienna logiczna o następującym znaczeniu: wartość True oznacza, że nisko położone słońce świeci
# wprost w oczy kierowcy. Wprawdzie ciemno nie jest, ale w takich warunkach światła powinny się zaświecić, oczywiście
# jeśli jesteśmy w trybie automatycznym
#
# isRainy - zmienna logiczna o następującym znaczeniu: wartość True oznacza, że pada deszcz, jest mgła lub mamy
# do czynienia z innymi niekorzystnymi warunkami atmosferycznymi. O ile jesteśmy w trybie automatycznym, to należy
# zaświecić światła
#
# Do zmiennej turnLightsOn zapisz wynik wyrażenia, które w oparciu o w/w zmienne ustali, czy światła mają zostać
# zapalone czy nie. Potem wyświetl wynik korzystając z instrukcji:
#
# print("Automatic mode: ",isAutomaticMode)
# print("Is the light good:",is80PercentLight)
# print("Is sun low: ",isDirectLight)
# print("Is it rainy: ",isRainy)
# print("TURN LIGHTS ON: ",turnLightsOn)
# Przetestuj działanie wyrażenia zmieniając początkowe wartości zmiennych wejściowych, np:
isAutomaticMode = True
is80PercentLight = True
isDirectLight = True
isRainy = True
turnLightsOn = isAutomaticMode and (not is80PercentLight or isDirectLight or isRainy)
print("Automatic mode: ",isAutomaticMode)
print("Is the light good:",is80PercentLight)
print("Is sun low: ",isDirectLight)
print("Is it rainy: ",isRainy)
print("TURN LIGHTS ON: ",turnLightsOn)
# isAutomaticMode = True
# # is the level of day-lighr above 80%
# is80PercentLight = True
# # is the Sun ligthing directly into the driver's face
# isDirectLight = False
# # is it rainy, foggy or other weather conditions are present
# isRainy = False
isAutomaticMode = True
is80PercentLight = True
isDirectLight = False
isRainy = False
turnLightsOn = isAutomaticMode and (not is80PercentLight or isDirectLight or isRainy)
# >> światła powinny się NIE świecić
print("Automatic mode: ",isAutomaticMode)
print("Is the light good:",is80PercentLight)
print("Is sun low: ",isDirectLight)
print("Is it rainy: ",isRainy)
print("TURN LIGHTS ON: (False)",turnLightsOn)
isAutomaticMode = True
is80PercentLight = False
isDirectLight = False
isRainy = False
turnLightsOn = isAutomaticMode and (not is80PercentLight or isDirectLight or isRainy)
# >> światła powinny się świecić
print("Automatic mode: ",isAutomaticMode)
print("Is the light good:",is80PercentLight)
print("Is sun low: ",isDirectLight)
print("Is it rainy: ",isRainy)
print("TURN LIGHTS ON: (True)",turnLightsOn)
isAutomaticMode = True
is80PercentLight = True
isDirectLight = False
isRainy = True
turnLightsOn = isAutomaticMode and (not is80PercentLight or isDirectLight or isRainy)
# >> światła powinny się świecić
print("Automatic mode: ",isAutomaticMode)
print("Is the light good:",is80PercentLight)
print("Is sun low: ",isDirectLight)
print("Is it rainy: ",isRainy)
print("TURN LIGHTS ON: (True)",turnLightsOn)
isAutomaticMode = True
is80PercentLight = True
isDirectLight = True
isRainy = False
turnLightsOn = isAutomaticMode and (not is80PercentLight or isDirectLight or isRainy)
# >> światła powinny się świecić
print("Automatic mode: ",isAutomaticMode)
print("Is the light good:",is80PercentLight)
print("Is sun low: ",isDirectLight)
print("Is it rainy: ",isRainy)
print("TURN LIGHTS ON: (True)",turnLightsOn)
isAutomaticMode = True
is80PercentLight = False
isDirectLight = False
isRainy = True
turnLightsOn = isAutomaticMode and (not is80PercentLight or isDirectLight or isRainy)
# >> światła powinny się świecić
print("Automatic mode: ",isAutomaticMode)
print("Is the light good:",is80PercentLight)
print("Is sun low: ",isDirectLight)
print("Is it rainy: ",isRainy)
print("TURN LIGHTS ON: (True)",turnLightsOn)
isAutomaticMode = False
is80PercentLight = True
isDirectLight = False
isRainy = True
turnLightsOn = isAutomaticMode and (not is80PercentLight or isDirectLight or isRainy)
# >> światła powinny się NIE świecić
print("Automatic mode: ",isAutomaticMode)
print("Is the light good:",is80PercentLight)
print("Is sun low: ",isDirectLight)
print("Is it rainy: ",isRainy)
print("TURN LIGHTS ON: (False)",turnLightsOn)
############################3
presence = 0.85
note = 3.5
finalWorkOK = False
print('you need to be present and have good notes or do the final work:', presence >= 0.8 and note >= 3 or finalWorkOK)
print('you need to be present and have good notes and do the final work:', presence >= 0.8 and note >= 3 and finalWorkOK)
presence = 0.4
note = 2.5
finalWorkOK = True
print('you need to be present and have good notes or do the final work:', presence >= 0.8 and note >= 3 or finalWorkOK)
print('you need to be present and have good notes and do the final work:', presence >= 0.8 and note >= 3 and finalWorkOK)