Gruparea condițiilor în Python

Deși operația and are prioritate asupra or, de multe ori este mai convenabil să folosim paranteze rotunde de grupare pentru a arăta în mod explicit prioritatea operațiilor:

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

În codul de mai jos, indicați prioritatea operațiilor în mod explicit:

pythontst = 3
  
if tst > 5 and tst < 10 or tst == 20:
  print('+++')
else:
  print('---')
Задание 2

În codul de mai jos, indicați prioritatea operațiilor în mod explicit:

pythontst = 3
  
if tst > 5 and tst > 0 and tst < 3:
  print('+++')
else:
  print('---')
Задание 3

În codul de mai jos, indicați prioritatea operațiilor în mod explicit:

pythontst = 3
  
if tst == 9 and tst > 10 and tst < 20 or tst > 20 and tst < 30:
  print('+++')
else:
  print('---')