What is Programming?

Computer programming is the way to develop sets of instructions for your computer.

These instructions are called computer programs. Everything your computer does is completed by using a computer program.

Here are a few examples of computer programs:

  • A computer operating system
  • Video games
  • Web browsers like Mozilla Firefox and Apple Safari
  • An application used for writing

Let’s try to see if you recall what computer programs are:

What else do you think is an example of a computer program?

  • a) Microsoft Windows
  • b) Google Chrome
  • c) All of the above !

To help your computer operate smoothly you need to write your program in the language it can understand. Which brings us to our 2nd lesson: Getting to know Java.

What is Java?

Java is the programming language used to teach the basics of computer programming. It is object-oriented. This means you can command your computer to complete tasks in the best and simplest way possible.

Java does this by instructing your computer to organize the data stored in it before executing your commands.

Java is simple and easy to learn, and one of the easiest ways to begin learning coding. It is used in a lot of computer and digital technology. Here are some examples you might know:

  • Android mobile operating system
  • Opera Mini
  • Komik Reader
  • jQuery

Here's an example of what a Java program looks like

coding

Let’s test your memory:

1) Java is:

  • a) A programming language used to teach the basics of learning.
  • b) A programming language used to teach the basics of programming.
  • c) A programming languages used to teach the basics of the internet.

2) Java is easy to use because:

  • a) It makes learning computer programming faster than the speed of light
  • b) It helps your computer complete tasks by organizing data first, then executing your commands
  • c) It helps your computer learn how to read and understand the English language

Up next: Now you know what a programming language is for, it’s time to know the rules for creating commands in it.

Writing Your Instructions According to the Right Syntax

Your computer does not understand English; it can only execute commands in programming language.

So how do you communicate with your computer? By creating your computer programs according to a strict set of rules called syntax.

Syntax is the set of rules on how to use words, punctuation marks, and symbols in programming. It takes a lot of practice to improve and master computer programming.

Java uses a lot of symbols that you might be familiar with like:

  • Parentheses - ()
  • Semicolons - ;
  • Curly brackets - {}
  • Forward slash - /
  • Plus sign - +, and a lot more!

Java also uses commands called expressions and statements. Expressions look a lot like mathematical calculations, while statements are made up of phrases and punctuation symbols.

Here are two examples:
Expression

  • 1 * 2 * 3
  • x + y / 100 // ambiguous
  • (x + y) / 100 // unambiguous, recommended

Statement

  • // assignment statement
  • aValue = 8933.234;
  • // increment statement
  • aValue++;
  • // method invocation statement
  • System.out.println("Hello World!");
  • // object creation statement
  • Bicycle myBike = new Bicycle();

Let’s see how much you understood about syntax:

1) Which of the following symbols is used in programming?

  • a) Parentheses - ()
  • b) Forward slash - /
  • c) Answers a and b

2) Syntax is

  • a) A set of rules for learning to write in the English language
  • b) A set of rules for learning to write in a programming language
  • c) A set of rules for learning to master storytelling

Lesson Racap

And you’re done with Lesson #1! How difficult was that? Remember that in creating computer programs, practice makes perfect. The more you create, the better you’ll be at it.

So let’s sum up what we’ve learned so far:

  • Computer programming is the way of developing sets of instructions for your computer. These instructions are called computer programs.
  • Java is the programming language used to teach the basics of computer programming. It is easy to learn. It is one of the best ways for kids like you to learn programming. It is object-oriented which means you can command your computer to complete tasks in the simplest way possible.
  • Syntax is the set of rules on how to use words, punctuation marks, and symbols in a pattern that your computer will understand.

Up next: Information is called different names in computer programming. Our next lesson will tell you want “data” is and why “variables” are important to programming.

What are Data and Variables?

Data is what we call the information that is stored in our computers. Data can be composed of numbers and words, as well as sounds and images.

Computers can access, store, or manipulate data depending on the commands you give it. And to help your computer do that, it uses variables.

A variable is used for categorizing, classifying, and storing different kinds of data together. They are labels you can use to name your data, or group of data.

For example :

  • 1+1+1 is assigned to the variable “math”
  • lion+tiger+cheetah is assigned to variable “cats”
  • rose+lily+orchid is assigned to variable “flowers”

Let’s do a quick review of this lesson:

1) Computers access, store, and manipulate:

  • a) Robots
  • b) Data
  • c) People

2) A variable is used for:

  • a) Categorizing and classifying flowers
  • b) Categorizing and classifying cats
  • c) Categorizing and classifying data.

Types of Data Used in Programming

We use different types of data for computer programming. There are a lot of types of data. For now, let’s focus on the two basic types: Numbers and Strings.

Numbers
Because the programming languages involve a lot of math, numbers are the easiest types of data for computers to understand.

Numbers are also the simplest way for you to give your computer programs.

You can write commands for your computer to add, subtract, multiply and divide. The symbols we use to make these calculations are call operators. These are: +, -, *, and /.

Strings
A string is a line of characters and may combine words and letters with numbers, punctuations, and spaces.

For example :
String str1 = "Hello World!";
String str2 = new String("Hello Everyone!");

The answer would be:

Hello World

Hello Everyone

That’s not all: You can also assign both numbers and strings to the same variable. When you do, you’re actually writing code—commands for your computer to execute.

For example :

  • a) Example variable string
  • b) Result of sample variable string

Let’s test to see if you can recall one key knowledge from this lesson: What are the two most common data types?

  • a) Numbers and Letters
  • b) Numbers and Strings
  • c) Numbers and Integers

Case-Sensitivity and Correct Variable Assignment

The Importance of Naming Your Variables Correctly

Case-sensitivity is the correct use of upper and lower case letters—when and when not to capitalize letters. It is very important to computer programming.

Variable names are case-sensitive, and variables cannot fulfill their jobs if they are named incorrectly. That’s why following programming syntax is so important.

For example: If you accidentally used a lowercase “g” in "tenGoodluckcharms", you’ll get an error, like:

  • tengoodluckcharms / tenBrothers;
  • ReferenceError: numberOfcandies is not defined

Assigning Value to Your Variable

How you position your variables is also important. Your variable should be on the left side, followed by an equal sign, and followed next by the data that’s assigned to it. See the example below:

You have a variable called “math.” Then, you assign the data below to it.

  • math = 1+1+1

Now that your variable has there is a value assigned to it, you can start writing your programming code. Here’s an example of how we can use your variable:

  • answer = math
  • sum = math

Or, you can start being creative:

  • math = math + 1
  • show(apples);

Because you have a calculation assigned to “math” which is “1+1+1”, your code will show the answer of 4.

Congratulations! You’ve completed the final topic in this lesson. Let's see what you’ve learned so far:


1) What is the key to creating variables that your computer can read?

  • a) Case-Sensitivity
  • b) Creativity
  • c) Consistency

2) When you’re writing your programming code, what should be on the left side of the code?

  • a) Data
  • b) Equal Sign
  • c) Variable

Lesson Recap

Data and variables are important in creating computer programs. Without them, you won’t be able to go far or do much. So here’s a quick recap of our lesson on them:

  • Make sure you spell your variables in exactly the same way every single time. Case-sensitivity is important.
  • Numbers and Strings are the two most common data types. Numbers are the simplest way to create programs, strings can help you write more advanced computer programs.
  • Variables can hold all kinds of data. Remember that your variable should be positioned on the left-hand side of your screen, followed by an equal sign, followed by the data you assigned to it.

You’re halfway to completing the basics of computer programming—you’re making great progress! Up next, we’ll be learning about Control Structures.

What are Control Structures?

Control structures , or control statements, are a type of command to give to your computer.

They help your computer act or respond to a given situation in different ways. They can also help your computer can do a series of actions in a specific way, and make decisions at crucial stages.

There are many types of control structures. For our tutorial, we’ll discuss two of most important and basic ones: the If-Else Statement; and the Switch Case Statement.

The If-Else Statement and its uses

The If-Else Statement gives your computer the two decisions to make:

  • 1) The first part of the statement —the “if” part—requires only one direct action (going outside to play or enjoying dessert).

    The If statement would look something like these examples:

    • a) If my homework is done, I can go outside to play.

    • b) If I finish dinner, I can have dessert.

  • 2) The second half of the statement—the “else” part—adds a condition. Based on this condition, the computer is required to make a decision.

    This statement would look like these examples:

    • a) If my homework is done, I can go outside to play, else I will stay in.

    • b) If I finish dinner then I can have dessert, else I can’t have any.

Another name for the If-Else statement is "Conditional Statement." That’s because the result of the statement depends on the condition that affects which decision your computer is required to make.

The Switch Case Statement and its Uses

When you’ve mastered the If-Else Statement, the next challenge is to create a programming code that lets you command your computer to make more than three decisions.

To help you do that , we will use the Switch Case Statement.

The Switch Case Statement is designed to stack two or more If-Else Statements into one programming code. Instead of having a lot of if-else statements, all you need is a Switch statement and you’re good to go. Switch Statements are the building blocks of computer games and animation.

Here’s an example of how a Switch statement might work: [Please add example of Switch Statement here]


Let’s see how much you’ve learned so far:

  • 1) Which one is an example of a control structure or statement?

    • a) CPU
    • b) Optical Drive
    • c) Switch Case

  • 2) Identify what kind of statement this is:
    “If my homework is done, I can go outside to play.”

    • a) If-Else Statement
    • b) Switch Case Statement
    • c) Syntax Statement

Lesson Recap

Congratulations! You’re one step closer to completing this tutorial! Let’s do a quick recap on the latest lesson we finished:

  • The control structures are commands you create for your computer. They help your computer make decisions. The two most basic types of control structures are the If-Else Statement; and the Switch Case Statement.
  • The If-Else Statement commands your computer to do two things:
    • First, to do an action;
    • Second, to react to a condition. You computer can do this by deciding to continue with the first action or choosing an alternative action.
  • The Switch control structure lets you command your computer to do a series of tasks (actions + decisions) with just one statement, making computer programming easier to do.

Now you that you know how to give your computer commands, let’s show it how to process the information you give it. Ready for the last lesson?

What is Sorting?

Sorting is a process of collecting and storing information in a consistent and understandable way.

With a sorting algorithm, you can arrange data (a.k.a., information) however you want to. You can sort your data in:

  • a) Ascending order (Smallest to largest)
  • b) Descending order (Largest to smallest)
  • c) Alphabetically (if you’re sorting names, for example)
  • d) Or by dates (if you’re sorting birthdays!)

To help with Sorting, you’ll need to know what an algorithm is.

What is an Algorithm?

An algorithm is a programming code that helps you arrange and store data in a certain order. It is a procedure that your computer follows to perform tasks.

In Sorting, an algorithm would help your computer take the elements—in Sorting, a piece of data or information is called an element—and arrange them according to the order you set. Algorithms are used to do both simple tasks and complex operations like games and animation.

Sorting Algorithms

One of the most popular—and most fun!—sorting algorithm used by many programmers is called Bubble Sorting.

What is Bubble Sorting

Bubble Sorting is a simple and effective type of sorting algorithm.

It’s a programming command that tells the computer to swap the elements if they are in wrong order. It will continue to swap the elements until all the data is arranged in proper order.

Bubble Sorting does this by:

  • 1) Comparing the first two elements in an array—or a row.
  • 2) Swapping one element with another. It does this according to the order you encoded into the program.
  • 3) Continuing to swap all the elements until they are arranged according to the order you want.

To make sure all the elements have been sorted correctly, the Bubble Sorting algorithm runs through the elements one more time to be sure.

Here’s an example of that sorting process:


function bubbleSort(arr){
   var len = arr.length;
   for (var i = len-1; i>=0; i--){
     for(var j = 1; j<=i; j++){
       if(arr[j-1]>arr[j]){
           var temp = arr[j-1];
           arr[j-1] = arr[j];
           arr[j] = temp;
        }
     }
   }
   return arr;
}
bubbleSort([7,5,2,4,3,9]); //[2, 3, 4, 5, 7, 9]
bubbleSort([9,7,5,4,3,1]); //[1, 3, 4, 5, 7, 9]
bubbleSort([1,2,3,4,5,6]); //[1, 2, 3, 4, 5, 6]
        


Let’s find out what you’ve learned about Sorting:

  • 1) Which order below is an example of what Sorting can do for you?

    • a) Ascending Order
    • b) Number Order
    • c) Rising Order

  • 2) What is data called in Sorting?

    • a) Byte
    • b) Element
    • c) Info

  • 3) What sorting algorithm did we use as an example in this lesson?

    • a) Alphabetical Sorting
    • b) Bubble Sorting
    • c) Rapid Sorting

And you’re done!

You’ve completed a tutorial on the basics of computer programming. Before we end, let’s do one final recap of this last lesson:

  • Sorting is a way to collect and store your data in your computer in a logical and consistent way.
  • An algorithm is a process that computers use to do things—from simple tasks to complex operations like games and animation. A sorting algorithm is a procedure used to put together data in a certain order.
  • Bubble Sorting is the simplest—but most fun and popular—type of sorting algorithm. It works by swapping the adjacent elements if they are in wrong order repeatedly until they are arranged in proper order.

Summary

  • Programming is the way of developing sets of instructions for your computer. These instructions are called computer programs. Computer programming can be done in a wide variety of programming languages. Java is one of the most popular and easy-to-learn programming languages.
  • Syntax is the set of rules on how to use words, punctuation marks, and symbols in a pattern according to the programming language you use. It is important when you’re creating your programming code because your commands need to be understandable to your computer for execution.
  • Data and Variables are building blocks of your programming code. They can come in different types, with the two most basic types being Numbers and Strings. Variables on the other hand, are used to label and hold data, for use in programming.
  • Control structures are commands you create for your computer. They help your computer make decisions. The two most basic types of control structures are the If-Else Statement; and the Switch Case Statement.
  • Sorting is a way to collect and store your data in your computer in a logical and consistent way. It is an algorithm used to process and arrange data so that your computer can use the data according to what you need it for.

With these basic ideas, you’re ready to learn more, so don’t be shy about searching for more. Computer programming isn’t impossible and we’re sure you’ll find a lot of new things to discover out there!

Congratulations

on completing this tutorial!

We hope you had fun learning the basics of coding. This is just the beginning: there’s so much more out there for you to discover. Since you now know the basics of coding good luck with creating your own program.

ENJOY CODING!!

"You may now download your certificate, just enter your full name below. Thank you!"