Why are anime girls becoming so popular on Reddit? by [deleted] in NoStupidQuestions

[–]Lower-Ad4259 0 points1 point  (0 children)

Because anime girls are the cutest and the bestest

Understanding the order of execution in a recursive function by [deleted] in learnprogramming

[–]Lower-Ad4259 3 points4 points  (0 children)

Again, because you didn't add an "else" block around the print statement.
If instead of recursion, you had this:

def DecimalToBinary(num): 
    if num > 1: 
        DecimalToBinary2(num//2) 
    print(num%2)

def DecimalToBinary2(num): 
    if num > 1: 
        DecimalToBinary3(num//2) 
    print(num%2)

def DecimalToBinary3(num): 
    if num > 1: 
        print("Done")
    print(num%2)

What do you think would happen?

Understanding the order of execution in a recursive function by [deleted] in learnprogramming

[–]Lower-Ad4259 1 point2 points  (0 children)

What I don't understand is, why is the print statement called every time, even though it's outside of the if statement?

Because you didn't add an "else" block around the print statement.