Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Kyoma Group Title

Hi. For Problem Set 1, what do you mean by "initialize some state variables"? Really new to programming. Much help is appreciated.

  • 8 months ago
  • 8 months ago

  • This Question is Open
  1. Firebender Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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;

    • 8 months ago
  2. Kainui Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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!

    • 8 months ago
  3. rsmith6559 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

    • 8 months ago
    • Attachments:

See more questions >>>

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.