हेल्लो दोस्तों आज के इस पोस्ट में आपको Python Decision Making in hindi के बारे में पूरी तरह डिटेल्स से बताया गया है तो चलिए शुरू करते है
Contents
Introduction to Python Decision Making
जब आप एक certain code को ककसी condition के आिार पर execute करना चाहते है तो इसके लिए आप decision making apply करते है।
Python में आपको decision making के लिए कुछ statements provide ककये गए है जजनके आिार पर आप define कर सकते है की ककसी code को कब execute करना है और कब execute नहीीं करना है। इन statements को decision making statements कहा जाता है।
- if Statement
- if-else Statement
- nested if Statement
Python If Statement
If में define ककये गए statements केवि तब ही execute होते है जब condition true होती है। If statement define करने के लिए if keyword का प्रयोग ककया जाता है।
if condition:
#statements to be executed when above condition is true…
इसके बाद condition define की जाती है। यह condition basically एक expression होता है और evaluate ककये जाने पर इसका result या तो true या false होता है।
यदद expression का result true होता है केवि तब ही if block के statements execute होते है। Condition के false होने पर if block को skip कर ददया जाता है और उसका कोई भी statement execute नहीीं होता है।
if 5>3:
print(“5 is greater than 3”)
Python If-Else Statement
If-else statement को आप if statement का advanced version समझ सकते है। If statement के द्वारा लसिय condition true होने की situation को ही handle ककया जाता है।
लेकिन if-else statement द्वारा आप condition true or false दोनों प्रकार की situation को control कर सकते है।
If else statement को if और else keywords के माध्यम से define ककया जाता है।
if condition:
#statements to be executed when condition is true else:
#statements to be executed when condition is false
If block के statement तब execute ककये जाते है जब condition true होती है और else block के statement तब execute ककये जाते है जब condition false होती है।
if 10 < 5:
print(“10 is less than 5”) else:
print(“10 is greater than 5”)
Python elif Statement
If-else statement लसिय condition true और false होने की situation में ही कायय करता है। यदद आप multiple conditions को check करना िाहते है तो इसके लिए आपको elif statement use करना चाहिए।
यह statement if else की तरह ही define ककया जाता है। बस और conditions define करने के लिए if और else के बीि elif block भी add कर ददया जाता है।
यह statement if, elif और else keywords के द्वारा कायय करता है।
if condition:
#statements to be executed when if condition is true elif condition:
#statements to be executed when elif condition is true else:
#statement to be executed when all the above conditions are false
If और else के बीि आप ककतने भी elif blocks add कर सकते है। यदद if condition true होती है तो if block के statements execute हो जाते है।
If condition false होने पर elif condition evaluate होती है। यदद यह condition true होती है तो elif block के statements execute हो जाते है नहीीं तो else block के statements execute हो जाते है।
if 10 < 9:
print(“9 is greater than 10”) elif 9 < 10:
print(“9 is smaller than 10”) else:
print(“In appropriate condition.”)
Python Nested If Statement
जब एक if block के अींदर दूसरा if block define ककया जाता है तो वह nested if statement कहा जाता है।if 10 > 3: if 10 > 6:
print(“10 is greater than 3 and 6”)
reference link –
निवेदन:-आप सभी छात्र –छात्रों से निवेदन है की अगर आपको ये Topic(Python Decision Making in hindi ) अच्छा लगा हो तो कृपया आप इस वेबसाइट के बारे में अपने दोस्तों को जरुर बताये अगर कोई topic(Python Decision Making in hindi ) से संबधित प्रश्न हो तो कमेंट्स(comments) आपके लिए ही बना है और किसी Subject के लेकर भी कोई प्रश्न हो तो कमेंट करे