Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I see this code in my python reference guide, but no description.

I am asked a question like what does this do:

print 2 and 1-2 !=3

It returns True, but why?

1 Answer

0 votes
by (106k points)

In, Python != means "not equal to" and is a logical comparison. Break down the logical expression here:

2 and 1 - 2 != 3 

2 and -1 != 3 

2 and True 

True

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
2 answers
asked Oct 4, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...