DEV Community

iamafruz777
iamafruz777

Posted on

if else haqida

Assalamu aleykum hurmatli dasturchi bugun siz bilan Python dasturlash tilida if else haqida ko'rib chiqamiz

Python dasturlash tilida if .. else (shart amall) xaqida gaplashamiz

Python dasturlash tilida matematika mantiqiy amallarni qo'llab quvatlaydi.

If
Enter fullscreen mode Exit fullscreen mode

sozi ingliz tilidan "agar" deb tarjima qilinadi va deyarli barcha dasturlash tillarida shartlarni yozish uchun foydaniladi.

Else 


Enter fullscreen mode Exit fullscreen mode

ingliz tilidan "aks xolda" deb tarjima qilinadi if qismi bajarilmaganda else qismi ichidagi kod bajariladi

misol uchun:

Teng:
Enter fullscreen mode Exit fullscreen mode

a===b

Teng emas:
Enter fullscreen mode Exit fullscreen mode

a!=b

Kamroq
Enter fullscreen mode Exit fullscreen mode

: a<b

Kichik yoki teng:
Enter fullscreen mode Exit fullscreen mode

a <=b

katta:
Enter fullscreen mode Exit fullscreen mode

a > b

Katta yoki teng:
Enter fullscreen mode Exit fullscreen mode

a >= b

Keling endi misollar koramiz:

a = 5
b = 6
if a > b:
print("A katta b dan")

else:
print("A kichkina b dan")

Natija:
A kichkina b dan chiqadi

Va keling yana bitta misol koramiz:

a = 16
a = 16

if a==b & a==b:
print("A teng b ga ")
else:
print("A teng emas b ga")

Natija:
A teng b ga

Top comments (0)