Python-da boyuk ve kicik operatorlari
Iki qiymetin bir-biri ile mueqayisesi ucun
boyuk >,
boyuk ve ya beraber >=, kicik <,
kicik ve ya beraber <= operatorlarindan istifade olunur.
Elimizde tst deyisheni olsun:
tst = 3
Gelin bu deyishenin qiymetinin sifirdan boyuk olub-olmadigini yoxlayaq:
if tst > 0:
print('+++') # bu iwleyecek
else:
print('---')
Indi deyishenin qiymetini menfi edek:
tst = -3
if tst > 0:
print('+++')
else:
print('---') # bu iwleyecek
Indi deyishenin qiymeti 0 olsun. Bu halda
else bloku iwleyecek:
tst = 0
if tst > 0:
print('+++')
else:
print('---') # bu iwleyecek
Gelin sherti boyuk ve ya beraber edek:
if tst >= 0:
print('+++') # bu iwleyecek
else:
print('---')
Sherti kicik ve ya beraber etsek, ilk blok yenə iwleyecek:
if tst <= 0:
print('+++') # bu iwleyecek
else:
print('---')
Bir deyishen verilib:
tst = 5
Onun 10-dan boyuk oldugunu yoxlayin.
tst deyisheninin 10-dan kicik oldugunu yoxlayin.
tst deyisheninin 5-dan boyuk ve ya beraber oldugunu yoxlayin.
tst deyisheninin -5-dan kicik ve ya beraber oldugunu yoxlayin.
Bir deyishen verilib:
tst = 5
Onun 10-dan boyuk oldugunu yoxlayin.
Asagidaki kod verilib:
if age >= 18:
print('You have access to the site')
else:
print('You do not have access to the site')
age deyishenine yawiniz uygun bir reqem teyin edin. Konsola neyin cap olundugunu deyin.