crazy python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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??

8th May 2020, 1:45 PM
Senthil Kumar
Senthil Kumar - avatar
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.
8th May 2020, 4:35 PM
HonFu
HonFu - avatar
+ 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
8th May 2020, 1:50 PM
Abhay
Abhay - avatar
+ 1
Excellent.
8th May 2020, 4:42 PM
Senthil Kumar
Senthil Kumar - avatar
0
I understood it's an comparison operator bit my question is I just used the statement blank
8th May 2020, 2:58 PM
Senthil Kumar
Senthil Kumar - avatar