Basics of Python

What is the output of the Python-2 code given below?

1
2
x=2
print x==3

False 3 True Error! 2

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Paola Ramírez
Apr 19, 2016

x = = 3 x==3 is the same as 2 = = 3 2==3 but 2 3 2\neq 3 . Therefore, the comparison is False \boxed{\text{False}}

Why wouldn't it return an error since parentheses are missing from the 'print' statement? Python doesn't allow you print statements like this. I've gotten errors in various editors because of the missing parentheses.

Akeel Howell - 4 years, 1 month ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...