Variables and Numbers

OK, Mr. CodePress, we’ve learned about letters, printing, and lists. Now, we get to the juicy part: variables. No, these are not like your variables in your math class; these variables are assigned numbers either randomly by the computer, using an algorithm by the computer, or entered using the input tag.

Using “Input”

Input is used to assign a variable to a number, letter, or word. They work with if-then tags (covered in the next post) to make great choice-designed programs (which are pretty much almost every useful program)

Test It Out:

1 print “What number”

2 input g

3 print ,g,

So, like in #3 in the program, to print the input variable, you must put commas around the variables and close any quotations, like this example below:

print “That’s the”,g,”number!”

The Algorithms

Now, what fun is the program above? Computers can create algorithms to make great calculators! This is a simple +1 calculator below:

1 print “This is the +1 calculator!”

2 print “Type a number”

3 input a

4 a = a + 1

5 print “Your answer is:”,a

The = sign in #4 is actually a “becomes sign!” For example, in this program below:

Where You Can Find Me

About Me

A little bit about how I created this blog: I was surprised how so little people (including me) knew how to code. I first learned coding (well, kind of) through a site made by MIT called scratch, and wow, how it was so simple made me striving to make great programs! I'm now learning how to really program. That's just a little bit about me. For more, you should go to my about page!

Learning Day

Our Next Learning Day!November 15th, 2014

Shush! I'm learning!

Follow Blog via Email

Enter your email address to follow this blog and receive notifications of new posts by email.

Program Delivery Service

Social Media

About Me

A little bit about how I created this blog: I was surprised how so little people (including me) knew how to code. I first learned coding (well, kind of) through a site made by MIT called scratch, and wow, how it was so simple made me striving to make great programs! I'm now learning how to really program. That's just a little bit about me. For more, you should go to my about page!