I have written following two codes in python in jupyter notebook. I expect the output of code 1 to be same as the output of code 2. But I get different output. Please help me to understand working of both the codes.
Explaining how shell output is different from compiled output is bonus.
Code 1
x = 2 # Line 1
y = 2 # Line 2
x==y # Line 3
x is y # Line 4
y is x # Line 5
Code 2
x = 2 # Line 1
y = 2 # Line 2
print(x==y) # Line 3
print(x is y) # Line 4
print(y is x) # Line 5
Output of Code 1 :
True
Output of Code 2 :
True
True
True