Data Types

A data type tells the program what kind of value something is and what can be done with it. Every value in a program has a type, and the type determines how the program stores and works with it.

For example, the number 42 and the text "42" look similar, but they are different types. You can add two numbers together, but adding two pieces of text just joins them into a longer string.

Primitive Types#

Primitive types are the most basic building blocks of data in a program. Here are the most common ones:

String#

A string represents text. Strings are written between quotes.

"Hello, World!"
"Welcome to Odds and Evens!"
"Hello, World!"
"Welcome to Odds and Evens!"
"Hello, World!"
"Welcome to Odds and Evens!"

Integer#

An integer represents a whole number, positive or negative, with no decimal point.

0
42
-7
0
42
-7
0
42
-7

Float#

A float represents a number with a decimal point. It is used when precision beyond whole numbers is needed.

3.14
-0.5
100.0
3.14
-0.5
100.0
3.14
-0.5
100.0

Boolean#

A boolean represents one of two possible values: true or false. Booleans are commonly used to make decisions in a program.

true
false
True
False
true
false

Resources#