+ 2

Why the output is different ?

def f1(): print('hello') print(f1) print(id(f1))

14th Oct 2020, 4:33 AM
Levi
Levi - avatar
2 Réponses
+ 10
it's the same number, but one is in decimal and the other in hexadecimal. proof: def f1(): print('hello') print(f1) print(id(f1)) print(f'{id(f1):x}') P.S.: id is the address in memory if I am right
14th Oct 2020, 4:46 AM
Jan Markus
+ 4
It's defferent because that number are in defferent base value example: 0123456789 this number is base 10 notation and some numbers has base 16 means it contains 16 digitis. there are four types of number system Binary numbers base 2 (0 or 1) Octal numbers base 8 (0 to 7) Decimal number base 10 (0 to 9) Hexadecimal number base 16 (0 to 9 and a to f) All the numbers represents the same value.
15th Oct 2020, 4:23 AM
Balaji
Balaji - avatar