0

Can any one explain me this code?

def is_even(x): if x == 0: return True else: return is_odd(x-1) #what this will do def is_odd(x): return not is_even(x) print(is_odd(17)) print(is_even(23))

3rd May 2020, 12:24 PM
Mahesh
Mahesh - avatar
5 Respostas
+ 6
Please take a pencil and a Sheet of paper and follow each step. Sooner or later you will understand. Understanding recursion is a long process that cant be done with a post here. your brain muscles must learn completely new moves.
3rd May 2020, 12:32 PM
Oma Falk
Oma Falk - avatar
+ 5
Kishalaya Saha cool stuff
3rd May 2020, 6:16 PM
Oma Falk
Oma Falk - avatar
+ 2
Hi Mahesh, I had tried to explain a similar code with smaller inputs many months ago. Maybe it'll help. https://www.sololearn.com/Discuss/1532322/?ref=app
3rd May 2020, 1:30 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Tq Kishalaya Saha
3rd May 2020, 1:40 PM
Mahesh
Mahesh - avatar
0
Ok tq
3rd May 2020, 12:50 PM
Mahesh
Mahesh - avatar