Last updated on 5/9/23

## Classify Data With Data Types A data type is simply a way to classify different types of variables. When you have a fruit, you can classify it as a particular type, such as apple or orange, for example. When you have a variable, the computer needs to classify it as a specific type as well: a data type. These are similar to the types of data you can use in an Excel spreadsheet: numbers, words, etc.

The most basic, or primitive, data types used in Python are:

• Integers

• Floats

• Strings

• Booleans

Wait, what? 😵  Primitive data types? Booleans? Is that even English?!

Don't worry! You'll have a few new terms to get used to as you learn to think like a computer, but we'll go through each of these together. 😎

Numeric types can fall into two categories in Python: integer or float.

An integer is any whole number:

• 1

• 4

• 3,934

A float is a decimal number:

• 3.14

• 563.2

• 99.9

Here are examples of variables with numeric data. Which are floats and which are integers?

• `conversion_rate = 3.2`

• `number_of_followers = 1304`

• `number_of_likes = 234`

• `episode_duration = 29.1`

If you guessed  `conversion_rate`  and  `episode_duration`  as floats and the other two as integers, you're correct!

Just like numbers in Excel or with a calculator, you can do all sorts of arithmetic operations with integers and floats in Python. Here are a few examples of the arithmetic operators you can use in your code:

• `x + y`: the sum of x and y (x plus y).

• `x - y`: the difference between x and y (x minus y).

• `x * y`: the product of x and y (x times y).

• `x / y`: the quotient of x and y (x divided by y).

• `x % y`: the remainder of x divided by y.

Playing around with arithmetic is a great way to practice some basic programming, so you'll find an exercise to help you do that at the end of this chapter.

Variables, data, and types, oh my! They aren’t so bad once you get some practice. Tackle this exercise on Replit to get a better feel for putting arithmetic in code. 😁

• navigating back to the course team page (click on the exercise title on the top left of your screen, then the team name "OCpythonbasics")

• clicking on "Fork the solution".

A string is just a fancy word for saying, well, words. A string is any information (usually text) that is surrounded by quotation marks (either single or double). So  `'hello'` in single quotation marks and `"hello"` in double quotation marks are both strings. So are `"goodbye"`  and  `"whatsup"` .

Some other examples of string variables:

• `greeting = "hi!"`

• `the_teacher = "Rina"`

• `first_name = "Sam"`

• `inspiring_quote = "You miss 100% of the shots you don’t take"`

Practice working with strings and explore some of the tricks to using them effectively in this exercise. 😁

Don't be intimidated by the funny name! A boolean is quite simple - it has only two options for its value: either  `True`  or  `False` .

Booleans can be very useful for saving whether something is successful or not.

For example, if you wanted to have a variable that could store the fact that it's sunny outside or not, you could say  `sunny_weather = True`. If it is not sunny, then  `sunny_weather = False`.

• A data type is a category or classification of the information in your code.

• There are many data types, but the most basic ones are float (decimal number), integer (whole number), boolean (True/False), and string (text in quotation marks).

Now that you know how to classify data with data types, we’ll go into more complex data objects, like lists.

Ever considered an OpenClassrooms diploma?
• Up to 100% of your training program funded
• Flexible start date
• Career-focused projects
• Individual mentoring
Find the training program and funding option that suits you best   