Lesson 8 of 34

if / else: निर्णय घेणारे प्रोग्राम

8 min 25 XP

if म्हणजे “हे true असेल तर हे कर”. 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 म्हणजे “नाहीतर”. Condition 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.

कोणत्या ओळी if च्या आहेत हे Python indentation वरून ओळखते. 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.