Nosacījumu grupēšana Python
Lai gan operācijai and ir prioritāte
pār or, bieži vien ir ērtāk izmantot
grupējošas apaļās iekavas, lai skaidri
parādītu operāciju prioritāti:
tst = 3
if (tst > 0 and tst < 5) or (tst > 10 and tst < 20):
print('+++')
else:
print('---')
Zemāk redzamajā kodā norādiet operāciju prioritāti skaidrā veidā:
tst = 3
if tst > 5 and tst < 10 or tst == 20:
print('+++')
else:
print('---')
Zemāk redzamajā kodā norādiet operāciju prioritāti skaidrā veidā:
tst = 3
if tst > 5 and tst > 0 and tst < 3:
print('+++')
else:
print('---')
Zemāk redzamajā kodā norādiet operāciju prioritāti skaidrā veidā:
tst = 3
if tst == 9 and tst > 10 and tst < 20 or tst > 20 and tst < 30:
print('+++')
else:
print('---')