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

please help. I am still very new to programming. was trynig to figure out the error that occurs you create a variable like this : variable= 0124

OpenStudy (nbarrera_t):

Is this a theoretical question or are you actually writing a program and you 're getting some error? If second case, please provide programming language and output error.

OpenStudy (anonymous):

yeah I support your answer @nbarrere_t if its not a theoritical question then provide a programming langauge and output error.thats the only way we can help you.

OpenStudy (rsmith6559):

The only errors that that statement can cause is that "variable" could be a reserved word by the language, it isn't in Python. The statement WILL give a surprising result: the leading zero means that 1234 is octal (base 8). >>> variable = 01234 >>> print variable 668

OpenStudy (e.mccormick):

Or to expand on why some people said it is language based, if you are in C, Java, or many others, you would need to tell it the type of variable: int variable = 01234 See, Python is dynamically strong typed. It uses what it sees about the input to determine the type. So as rsmith points out, the 0 at the start tells it to make an octal input. If it had quotes around it then it would fo it as a string. () make a tuple. On and on, Pythin automatically tupes, but once typed you can not simply use it as another type without reassigning to the needed type. That makes it strongly typed even though it is dynamic. C, C++, Java, BASIC, and a whole host of others want the variable type clearly written. There is nothing dynamic about them.

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!