## Data

- basic unit in programming.

## Data Type

**Primitives**

- Numbers
- Strings
- Boolean values (True or False)

## Numbers

**Describe**— numbers are used to express value: what is the frequency of a sound wave? We can express that in a number, such as 800hz.**Calculate**— numbers are used in calculations: what’s the distance between the earth and mars?**Count**— numbers are used to keep track: how many times did the car go around the track?

## Strings

- represent other forms of data other than numbers
- Strings are any sequence of characters (letters, spaces, numbers, or symbols). While almost anything can be a string, they are typically used to represent text or speech. Similar to how we represent speech in writing, we surround strings with single (
`'...'`

) or double quotes (`"..."`

).

**Uses of Strings**

- To display data that uses text or symbols, like printing our name to the screen.
- To add or remove text. Since strings are a linear sequence of characters, we can break strings into even smaller strings, or combine strings to make longer ones.
- To modify characters. For example, we could capitalize the first letter of every word in a string if wanted to turn it into a title.
- To let the computer communicate with us in a “human-readable” way, like displaying the rules of an online game.

## Boolean

- only have two values: true and false
- Logic is important to computer science because it is an early attempt at translating the human capacity for reason to computers.
- act as binary opposites

*The term boolean comes from the inventor of a specific form of logic, George Boole.*

**Uses of Boolean**

- To determine validity. For example, we want to know whether a meme is viral. If it’s been viewed more than 50 million times in less than a week, we’d say that it’s true that it went viral.
- To make decisions. For example, if I get an email, the program checks that the email is new and it displays at the top of my inbox.

## Operators

- Making calculations using
*arithmetic*operators. - Comparing information using
*comparison*operators. - Creating logical expressions using
*logical*(aka Boolean) operators. - are symbols that represent different ways of modifying, comparing, and evaluating information.

**Arithmetic Operators**

used to make calculations.

*Addition*adds an amount to a number:`2 + 3 = 5`

*Subtraction*takes away an amount from a number:`10 - 3 = 7`

*Multiplication*takes a number and repeats it a specified number of times:`5 * 2 = 10`

*Division*takes a number and divides it by another number:`15 / 3 = 5`

**Comparison Operators**

determine the relationship between two values, which results in a boolean.

- Less than
`<`

— value to the left is**less than**the value to the right:`2 < 6`

- Greater than
`>`

— value to the left is**more than**the value to the right:`14 > 5`

- Equals
`==`

— value to the left is**equal to**the value to the right:`3 == 3`

**If we have an unknown quantity.**

`strawberry_weight = ?`

is (strawberry_weight == .5lb)? => true

**If we need to compare two known values.**

bananas = 5

oranges = 3

is (oranges > bananas)? => false

**Boolean Expressions**

- Expressions that evaluate to boolean values are known,
`true`

or`false`

**Logical Operators**

determine the logical state of multiple boolean values or expressions, which results in another boolean.

- also known as boolean operators, evaluate multiple boolean expressions.
- it looks at several relationships by connecting them with logical operators and then determining the logic/validity of the overall expression.

**AND**— both expressions evaluate to true, so the final result is true:`((4 > 1) AND (2 < 7))`

is the same as`(TRUE AND TRUE)`

. Evaluates to true.

**OR**— one of the expressions evaluates to true, so the final result is true:`((8 > 6) OR (3 > 6))`

is the same as`(TRUE OR FALSE)`

. Evaluates to true.

**NOT**— an expression, no matter its logical value, evaluates to the opposite:`NOT (1 < 3)`

evaluates to`NOT (TRUE)`

. Evaluates to false.

The larger the sample size and the more diverse your dataset is, the more confident you’ll be in your results.