About quiz 2;operators

@shivrajrtandale98 here in quiz Q8 ans should be TRUE as both the set are same…
And also if we run it in compiler Output is TRUE.
Please can you look into it…


1 Like

Correct answer is false

in the last statement if you observe carefully (a is b ) that actually means is id (address) of a and b variable the same . Therefore the answer is False

@mohammedaliparkar342 Thank you I understood

1 Like

@mohammedaliparkar342 can u explain plz

1 Like

@gajendravenkatbsc i have provided the explanation above , if it is not clear please ping me again . i will solve it

@mohammedaliparkar342 yes I am new to python. I don’t understand is When I Execute this same code. It says true but u said it was false. I. Cannot understand it properly. Can you elaborate?

1 Like

Sure .

in the last statement .i.e print(a is b ) over here (is) is used to check the address of a and b variable .
Therefore the output is returning false .

if you check the id (address) of variable a and b it will be different . you can check it using → print(id(a) , id(b) )

@mohammedaliparkar342 In question it is not mentioned to consider address of a and b (like print(id(a) is id(b)) )
so how output will be False?
In compiler its showing True…

1 Like

Look into this . I have run the code and the answer is False and look at the id as well

@mohammedaliparkar342 ok but I my compiler it give meTrue so I get confused

1 Like