Monday, November 12, 2018

Variables

Let's talk about another useful tool for programming!

This tool is called a "variable"

A variable is a way to save information that you want to use for later.
Let's look at the above example again, we wrote a program that asked "What's your name?" but we never saved it to a variable. If you try to ask the computer to tell you your name it will not be able remember it. To solve this we can write the same code but using variables!

A variable is very easy to make all you need is one of these " = ". The = sign will create the variable for you as long as you put things in the right order.

Here is the order:
Name of the variable = information you want to be saved

Example:
apple_color = "red".

Now let's rewrite the pervious example this time using this web site
https://repl.it/repls/BowedDiscreteCodegeneration

You can make as many variables as you want but there are some important rules to keep in mind.
1. The variable name never goes inside of  " " quotation marks
2. The variable can be numbers, words, even other variables
2. If you want to save a word or sentence that you then that information must go inside of " " quotation marks

No comments:

Post a Comment

Introduction

Hello! Welcome to Coding for the Young Ones! This blog is to teach the basic principles of programming and Computer Science, specifically ...