Data: a basic unit in programming. Data represent the pieces of information that come together to make a program.
Primitives are the most basic types of data (or data types). We can find primitives in almost any kind of programming language.
- Boolean values (True or False)
We use numbers to describe, calculate, or count.
Describe: The distance around the block is 200 meters.
Calculate: 2 + 3 = 5
Count: Odd numbers between 2 and 10.
Strings are individual characters strung together. They’re mainly used to represent text or speech. We use single quotes ‘….’ or double quotes “….” to represent strings.
With strings, characters are being strung together into a sequence of symbols – similar to the connecting earring pods in a bracelet.
For example, this is a string: ’35’; and this is not a string: 35 (this is a numerical value). A string of characters is different from a numerical value.
We use strings to display data, add or remove text, modify characters, or display words.
Display data: using texts or symbols
Add or remove text: to break strings into smaller sizes, or combine individual strings into longer ones
Adjust characters: like capitalizing the first letter of every word in a string
Display words: give words on a scree, for example, instructions on a test.
Booleans have only two values true or false. So boolean values represent the logical ideas of true and false.
Booleans can take multiple binary (two-part) forms. For example, on or off, open or close, yes or no, 0 or 1, in or out.
We use booleans to show logic or rationality using set conditions, and to make decisions.
Show logic: For example, we can determine whether it’s a sunny day. So if there’s no rainfall and we get at least five hours of sunshine, then it’s true that it’s a sunny day.
Make decisions: If I input an incorrect password, the computer checks that the password matches its history, and, if not, it shows the message: ‘Incorrect Password.’