## Using Mathematica » Basics

## Types

Mathematica has 2 basic types of things in it:

- Numbers
- Words

It also has 2 basic ways to have multiple values together

- Lists
- Key-Value Sets

### Numbers

A number is simply any number you'd like, for example:

` ``1`

` ``1`

It can be real:

` ``2.1232`

` ``2.1232``

` ``-1.33`

` ``-1.33``

Irrational (You can access special characters by pressing `ESC` typing a shortcut and pressing `ESC` again)

` ````
π
E
I
```

` ````
π
```

` ``E`

` ``I`

Just as mathematicians distinguish between integers, real numbers, and complex numbers, so does Mathematica.

In general it is good practice to assume that if you can find a mathematical term on Wikipedia, you can find it in Mathematica, although its name may be a bit tough to discover.

### Words

A word is a string of letters or other characters enclosed in double quotes. Because it's a string of characters this type is called `String`

.

For instance, we can have a single character:

` ``"a"`

` ``"a"`

Or a sequence of them:

` ``"abcdefg"`

` ``"abcdefg"`

We can include punctuation:

` ``"Hi Mom!"`

` ``"Hi Mom!"`

And non-standard characters:

` ``"τ is my favorite irrational number"`

` ``"τ is my favorite irrational number"`

Mathematica has a built-in set of characters:

` ``""`

` ``""`

Finally, a `String`

can be of any length:

` ````
"When in the Course of human events, it becomes necessary for one people to dissolve the
political bands which have connected them with another, and to assume, among the Powers of the
earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle
them, a decent respect to the opinions of mankind requires that they should declare the causes
which impel them to the separation.
- Winston Churchill (1984)"
```

` ``"When in the Course of human events, it becomes necessary for one people to dissolve the \npolitical bands which have connected them with another, and to assume, among the Powers of the \nearth, the separate and equal station to which the Laws of Nature and of Nature's God entitle \nthem, a decent respect to the opinions of mankind requires that they should declare the causes \nwhich impel them to the separation.\n\n - Winston Churchill (1984)"`

### Lists

A `List`

is an ordered collection of any type of thing enclosed in curly brackets, for example:

` ``{1, 2, 3}`

` ``{1,2,3}`

A `List`

of `String`

:

` ``{"a", "b", "c"}`

` ``{"a","b","c"}`

A mixed-type list:

` ``{1, 2, {1, 2, 3}, {"a", "b", "c"}, 10, 11, 12 }`

` ``{1,2,{1,2,3},{"a","b","c"},10,11,12}`

We get values from lists using the `Part`

function, which can be typed as `[[ ]]`

, for example:

` ``{"a", "b", "c"}[[1]]`

` ``"a"`

We can also count from the end using negative indices

` ``{"a", "b", "c"}[[-1]]`

` ``"c"`

### Key-Value Sets

A key value set is a collection of `key->value`

pairs enclosed in `<| |>`

These are useful for associating things by key rather than having to find them by positions, because it's associating keys and values this type is called `Association`

, for example

` ``<|1->"a", 2->"b", 3->"c"|>`

` ``<|1->"a",2->"b",3->"c"|>`

We get values using the `Lookup`

function, which can be typed using `[ ]`

, for example

` ``<|1->"a", 2->"b", 3->"c"|>[1]`

` ``"a"`