This python code's aim is to convert decimal number to binary number. I know I can use int() function in the code but I am not able to determine the process that is happening in the code.
def decimal_to_binary(n):
if(n > 1):
decimal_to_binary(n//2)
print(n % 2 , end='')
print(decimal_to_binary(18))
# The output for it is : 10010None
It is said that when the program enters if condition , it will first the interprete the code inside the if statement so how can it perform the print(n % 2 , end='')
simultaneously. According to me, I think this print(n % 2 , end='')
will only print one value(0 or 1). To me, it seems recursion and the print statement after the if statement are being interpreted simultaneously.
And secondly, why None is also printed with output?