• anonymous
Hi. For Problem Set 1, what do you mean by "initialize some state variables"? Really new to programming. Much help is appreciated.
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
  • katieb
I got my questions answered at in under 10 minutes. Go to now for free help!
  • anonymous
whenever you want to use a variable you must do two things to it first declare it by stating what type it is and what name you want to assign the variable second, initialize it: meaning assigning a value to that variable (there are times when you don't need to do this, but at some point in the variable's "life" it gets initialized, it gets assigned a value. i.e. int myFavouriteNumber = 7;
  • Kainui
A couple other subtle things to sort of expand upon in Firebender's reply: int myFavoriteNumber = 7; The 'int' part is short for integer, you could easily have a boolean or string, depends. Since other people, including an older version of yourself that has no ideas what you did last week, will possibly read your code, it's common to name variables with the first letter lowercase and the rest of the letters uppercase, this is called "camel case" and is really kinda convenient to get into the habbit of. It makes variables stand out and easy to find. Also, notice he used = instead of ==. The difference is that basically a single equals sign is an assignment while double equals is a test of equality. Just thought I'd tack that on, cause I'm learning myself and just sort of trying to help!
  • rsmith6559
MIT 6.00 uses Python. In Python, when you create a variable you don't need to declare it's type, that will be handled by what you assign to it. For instance: intOne = 1 charOne = '1' floatOne = 1.0 intOne is and integer, charOne is a character/string variable and floatOne is a floating point (decimal) number. State is the current status of something. Part of my current state is that I'm sitting in my recliner. "initialize some state variables", without any clue what Problem Set 1 is, some possible state variables may be: import time, os currentTime = time.time() username = os.getenv( "USER" ) That code does work, but it's more to give you an idea of state variables. Kainui is right, "=" is the assignment operator. "==" compares for equality and gives a true/false result. It's not hard to get them wrong, but usually it's using the assignment operator when you meant to use the comparison operator. One of the great thing about computers is that they can do what you want. The most frustrating thing about computers is that they do what you tell them to. In programming, that's a huge difference.

Looking for something else?

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