In Python functional programming this code is valid and runs as expected:
def increment_5(num):
number = 5
number += num
disp_result(num)
def disp_result(num):
print(f"5 was increased by {num}")
increment_5(6) # -> 5 was increased by 6
I have created the disp_result() function after calling it. I have seen in other people's code (and I write in this way too) that they call functions after defining them and I believe this is the convention and good practice. But, as shown, we can also call a certain function before actually defining it. In OOP too, I can call a class method using self.certain_method() before acutally defining this method. So how is it achieved and is it something that happens in Python only?
I understand this question could have been asked before. If such, please know that I was unable to find it and linking to it would be helpful too.