Thursday, February 6, 2014

Weekly Reflection #2

This week, in the second chapter the book the chapter covered expressions, values, operators, and variables. In the last chapter the book went into the different programs that would go into use. But this week it breaks down a little more on actually using the programs instead of learning about what they do. Before I go any further I will mention that the first line of reading in this chapter states '[you] won't start programming in this chapter'. I learned about a few basic concepts that programming is built on. I started by opening a program called IDLE. IDLE is an interactive shell that works just like a calculator but can also process code. I was instructed to enter 2 + 2 into the shell.



The number 4 was returned. Just to show that the addition sign tells the computer to add the numbers. After that I entered a couple more different expressions.















This chapter so far pretty much covered really basic algebra defining what an expression was and how to store values into variables(spam = 15, if you took a box and wrote spam on it. You could then take any value and place it inside that box). Once you define a variable and place a value to that, you can use it in an expression.

For example:
If I define spam...or in this case Homework it'll look like this.

>>>homework = 15 #<---These forward slashes are for commenting. Anything that follows them will no be                                 #process by the compiler. The value of the homework is now 15. We homework has                                  #been defined and can now be used in an expression like so.
>>> homework + 10
25 #You have been returned the value 25 because 10 was added to your homework value(15)

You aren't limited to just one variable either. You can you multiple variables.

Like so:
>>> EOP = 310
>>> CSUN = 16
>>>homework = EOP + CSUN #Here I've assigned a new value to homework. So when I typed               >>>homework
326                                                  #homework in I get this...

That's pretty much what I've learned for this week.

No comments:

Post a Comment