Taking a Vacation(Can someone tell me the differences?)


#1



I am confused about the differences between this two codes below, and is it the same?


Replace this line with your code. 
answer = 42

def answer():
    return 42


#2

answer = 42
At first line of code answer belongs to int class.

but when you write this.. (Dynamic Typing)

def answer():
    return 42

You created a function with same name ,Its not longer an integer or belong to int class but now It belongs to 'function class'.

so when you try to print answer
print answer

You will get something like this -- > <function answer at 0x039F4738>

A good discussion to look at..
LINK


#3

thank you for the reply!I have more understanding of variables and functions now.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.