# Python for Basic Data Analysis

Start your data science journey with Python. Learn practical Python programming skills for basic data manipulation and analysis.

## Data Types

#### Data types

Data types are the classification of data items. Data types represents a kind of value which determines what can be done to that data.

What are the different types of data in Python?

Data Types Examples Explanation Mutable/Immutable?
Strings "Hello!", "23.34" Text - anything between
" "  becomes string
Immutable
Integers 5364 Whole numbers Immutable
Floats 3.1415 Decimal Numbers Immutable
Booleans True, False Truth values that represent Yes/No Immutable
Lists [1,2,3,4,5] A collection of data,
sits between  [ ]
Mutable
Tuples (1,2,3,4,5) A collection of data,
sits between  ( )
Immutable
Dictionaries {"a":1, "b":2, "c":3} A collection of data,
sits between  { }
Mutable

#### How do you set data types?

Data types are set when you assign a value to a variable.

Examples Type Explanation
ex_1 = "Hello World" string The data assigned sits in between  " "
ex_2 = 254 integer The data assigned does not sit in between  " " , and is a whole number
ex_3 = 25.43 float The data assigned does not sit in between  " " , and is a decimal number
ex_4 = ["Anna", "Bella", "Cora"] list A list of strings - Data assigned sits in between  " " , within  [ ]

#### How do you check data types?

Use the  type( )  function to check data types.

type(x)  determines and returns what is the type of the input x

Click the triangle button to run the codes and see the output:

#### Type conversion

To convert variables from one type to another (i.e. integers to floats), we use type conversions as follows:

Data Type Syntax
strings str()
integer int()
floats float()
lists list()

Application

## Exercises

1. Determine and print the type of the following variables

• variable1 = 123
• variable2 = "123"
• variable3 = 123.456

2. Convert the following variables print the result

• Convert this float into an integer
• variable4 = 23.0
• Convert this string into an integer
• variable5 = "6000"