x=3
x= x*x
print x
for the above i am not getting 9
on phyton 3 can i knwo why?
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (alprincenofl):
I am not studying Phython but I think it calls the first "x" which equals "3".
I think you have change the next line to make it an update or something like that
OpenStudy (harsha19111999):
I think you have to do "y=x*x"
OpenStudy (alprincenofl):
@Harsha19111999 good point!
OpenStudy (harsha19111999):
:)
OpenStudy (anonymous):
No, you should be getting 9. It seems like the second line is being ignored
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (woodrow73):
I'm a python noob, but to print x I think you simply do
```
x
```
and it should print out as whatever x's value is; ie:
OpenStudy (anonymous):
That only works when running python in interactive mode, which will print the value of an expression so long as the value isn't `None`. If you actually want to write to stdout, then you would use print.
OpenStudy (woodrow73):
I see.
OpenStudy (rsmith6559):
You're using Python v2 syntax in Python v3. Try:
print( x )