Lesson 8 of 34

if / else: फ़ैसला लेने वाले प्रोग्राम

8 min 25 XP

if का मतलब है “अगर यह सही है, तो यह करो”। if वाली लाइन : (colon) से ख़त्म होती है, और उसके नीचे की लाइनें 4 spaces अंदर लिखी जाती हैं।

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

else का मतलब है “नहीं तो”। जब शर्त False हो, तो else वाला हिस्सा चलता है। marks को 20 करें और Run दबाएँ।

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

उपयोगकर्ता जो टाइप करे, उसके आधार पर भी फ़ैसला हो सकता है। Input box में दूसरी उम्र डालकर Run दबाएँ।

Example: edit me and press Run

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.

Python indentation से पहचानता है कि कौन-सी लाइनें if के अंदर हैं। Tab key का उपयोग करें।

Challenge

+25 XP

input() से एक संख्या पढ़ें। सम हो तो Even, नहीं तो Odd print करें।

Output Loading Python (first time takes a few seconds)
Press Run to see the result here.