A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • one year ago

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

  • This Question is Open
  1. nbarrera_t
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

  2. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  3. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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

  4. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.