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.