Programming Basics/Printable version
The current, editable version of this book is available in Wikibooks, the open-content textbooks collection, at
https://en.wikibooks.org/wiki/Programming_Basics
Introduction
Concepts
- What is programming?
- What is an algorithm?
- What is coding?
- What is a programming language?
- What is a translator?
Variables
Variables are tools which are used to store data.
Programming languages often use types to distinguish different kinds of data stored in variables.
| Data Type | Description | Example 1 | Example 2 | Example 3 |
|---|---|---|---|---|
| Integer | Any whole number. | 1 | 300 | 48 |
| Character | A letter of the alphabet. | a | z | y |
| String | A collection of text | Wikibooks | Programming Basics | Hello world! |
Functions
Functions used to store code that is used multiple times throughout a program, especially bits of code that repeat throughout a program.
Functions often take input to make them more versatile. This input is called an argument.
Conditions
Conditions are used in programming to only do something in the event of something else. This is incredibly useful in a number of tasks.
For example, one might prevent divide by zero errors by check to make sure the devisor is not zero first, and then only dividing if the devisor is not zero.
Loops
Loops are used to repeat sections of code, either infinitely, or until a condition is met.
There are two common types of loops, While loops and For loops.
Arrays
Arrays are used to hold multiple related variables.
| 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| A | r | r | a | y |
Strings

A string is a data type used to store sequences of characters. Strings are often simply an array of characters.
Files
Files are used to save data to a storage device, which is useful for a number of purposes.
Objects
Objects are a useful tool to handle flexible situations in code. Object Oriented Programming style uses objects extensively.