Blog

Conditional Statement in python in hindi - Bharosewale

Posted By Naveen Singh on 20 Mar 2023

python-program
python-me-conditional-statement-kya-hote-hai-in-hindi

Python में conditional statement क्या होते है?(What are conditional statement in python?)

 

Conditional statement in python in hindi

Python में conditional statement basically three types के होते है।

i) simple if else statement

ii) if elif else statement

iii) nested if else statement

 

Conditional statement in python with example

 

i) Simple if else statement-:

Simple if else condition  को लिखने के लिए हम if keyword का use करते है, जिसमें syntax कुछ इस प्रकार से होता है।

Syntax-:

if  expression:

   statement

else:

   statement

Example-:

x = 4

if x>0:         # x>0 एक expression है

   print("positive number")

else:

   print("negative number")

Output-:

positive number


ii) if elif else statement-:

इसमें हम एक से ज्यादा if else statement का use कर सकते हैं।

Syntax-:

if expression:

   statement

elif expression:

   statement

else:

   statement

Example-:

a = 5

b = 4

if a>b:                      # a>b एक expression है

   print(" a is greater")

elif a<b:                   # a<b एक expression है

   print(" b is greater")

else:

   print("both are equal")

Output-:

a is greater


 

iii) nested if else statement-:

Condition के अन्दर condition को हम nested if else condition कहते है।

Syntax-:

if expression:

   if expression:

      statement

   else:

      statement

else:

   statement

 

Example-:

a = 6

if a>0:   

   if a%2==0:

      print("even number")

   else:

      print("odd number")

else:

   print("negative number")

 

Output-:

even number


Conclusion
 

I Hope आपको Python में conditional statements क्या होते है? conditions python में कैसे work करता  है, और conditional statements के types के बारे में आपको जानकारी मिली होगी। यदि आपको कोई doubt है तो comment section में comment करके पूछ सकते हैं।


 

Comments