Prioritet operacija poređenja u Pythonu

Operacija and ima prioritet nad or, tj. ona će se u uslovu izvršiti prva.

U sledećem primeru uslov će se aktivirati, ako je promenljiva tst od 0 do 5 ILI od 10 do 20:

pythontst = 3

if tst > 0 and tst < 5 or tst > 10 and tst < 20:
  print('+++')
else:
  print('---')
Задание 1

Dat je sledeći kod:

pythontst1 = 5
tst2 = -5

if tst1 > 0 and tst1 < 7 or tst2 > -10:
  print('+++')
else:
  print('---')

Recite kojim redosledom ovde ide poređenje.

Задание 2

Dat je sledeći kod:

pythontst1 = 1
tst2 = 10

if tst1 < 5 or tst2 > 9 and tst2 < 15:
  print('+++')
else:
  print('---')

Recite kojim redosledom ovde ide poređenje.