Types

In programming, variables can hold different types of things and these things can have different behavior.

For example, you might put clothes or an elephant in a drawer or box as long as the drawer or box had holes.

Clothes have different actions that can be done with them. You can put them on, but you cannot put on an elephant.

In the Values section, the "Numbers" and "Text Strings" are different types. With numbers, the + sign adds the values using addition. With the text strings, the + sign copies (appends) the one and two together.

The "type()" Keyword

It is possible to see what type is in a variable. Notice that the variable can have contain different types at different times. Some programming languages do not allow this.

Here is an example where the '*' is used with a number and text. What happens if '1' * '2' is performed?

The result of some action can be different than the types that were used in the action. The following makes a type that is a different kind of number.

The type says 'float', but in programming, this is called 'floating point', because it has a decimal point.