Lesson 22 of 34

return: பதிலைத் திருப்பித் தருதல்return: Giving Back an Answer

8 min 30 XP

print() திரையில் காட்டும் மட்டும். return ஒரு மதிப்பை அழைத்த இடத்துக்கே திருப்பித் தரும்; அதை variable-ல் சேமிக்கலாம், கணக்கில் பயன்படுத்தலாம்.

print() only shows something on screen. return hands a value back to the caller, so you can store it or use it in calculations.

Example: edit me and press Run

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

return வந்தவுடன் function உடனே முடிந்துவிடும். return இல்லாத function None என்பதைத் தரும்.

A function stops as soon as it reaches return. A function without return gives back None.

Example: edit me and press Run

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

இனி வரும் சவால்களில், மறைக்கப்பட்ட சோதனைகள் உங்கள் function-ஐ வேறு மதிப்புகளுடன் அழைத்துப் பார்க்கும். அதனால் return சரியாக இருக்க வேண்டும்!

From now on, hidden tests will call your function with other values. So your return value must be right!

Challenge

+30 XP

is_even(n) என்ற function எழுதுங்கள். n இரட்டைப்படை என்றால் True, இல்லையெனில் False என்று return செய்ய வேண்டும் (print அல்ல!).

Write a function is_even(n) that returns True if n is even, otherwise False (return, not print!).

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