+ 2
crazy python
a = 1 a == 0 print(a) i am not getting any error @ second line. because a is already defined. actually what will happen at second line??
4 Answers
+ 2
Every expression (everything that has a 'value') can just sit in your code.
You could write this and it wouldn't cause an error:
print('Hello')
1
5+6
'Nobody hears me'
True
...
7==5
print('Bye')
Python doesn't mind if you write values.
However, if you don't *do* anything with the values, nothing (visible) will happen.
It's like:
You: 42
Python: Okay, and what of it?
You: Well...
Python: As you wish. What next?
The object will just be created, then directly forgotten again.
+ 7
Why would you get error ?
At second line you are comparing a's value to 0
Like a==0
So it's 1==0
it will therefore return false
+ 1
Excellent.
0
I understood it's an comparison operator bit my question is I just used the statement blank