Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 21 Online
OpenStudy (anonymous):

x=3 x= x*x print x for the above i am not getting 9 on phyton 3 can i knwo why?

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

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 )

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!