The if...else Statement :-
if...else statement Python का एक Conditional Statement (शर्तीय कथन) है। इसका उपयोग किसी condition को check करने के लिए किया जाता है।
यदि condition True (सही) होती है, तो if block के अंदर लिखा code execute होता है।
यदि condition False (गलत) होती है, तो else block के अंदर लिखा code execute होता है।
Python में if और else के अंदर लिखे code को Indentation (रिक्त स्थान) देना आवश्यक होता है। Indentation यह बताता है कि कौन-सा statement if या else block के अंदर है। सामान्यतः Python में 4 spaces का indentation प्रयोग किया जाता है।
English
The if...else statement is a conditional statement in Python. It is used to check a condition.
If the condition is True, the statements inside the if block are executed.
If the condition is False, the statements inside the else block are executed.
In Python, the code written inside the if and else blocks must be given Indentation (spaces). Indentation indicates which statements are part of the if or else block. Generally, 4 spaces are used for indentation in Python.
Python में if...else statement को एक ही line में भी लिखा जा सकता है। इसे Shorthand if...else Statement, One-Line if...else Statement या Conditional Expression कहा जाता है।
EnglishIn Python, an if...else statement can also be written in a single line. This is called a Shorthand if...else Statement, One-Line if...else Statement, or Conditional Expression.