# Data Types in Python

In this section of the Python tutorial, Python Data types are elaborated in detail.

## Numbers

### Integers

An integer is a number that can be written without a fractional element.

For example, 21, 4, 0, and −2048 are integers, while 9.75, 5 + 1/2, and −2048 are not an integer. Python supports Integers’ number.

Similar to C programming language, Python Integers is denoted as int.

### Floating Point Numbers

A floating-point number is a value made up of two parts. A portion that internally represents the important digits of the value often referred to as the mantissa and a component that specifies the position of the decimal point, i.e. the power or exponent to which the base is lifted, which is then compounded by the mantissa.

Integers and floating points are separated by the presence or absence of a decimal point. 5 is integer whereas 5.0 is a floating-point number.

Examples are 25.04, -25.52, 15.567845321, 3.0 etc.

Python supports the Floating point number and it is denoted as float.

### Complex Numbers

A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers, and i is a solution of the equation x2 = −1.

Python supports the Complex numbers and it is denoted as the complex.

## Strings in Python

A string is a character set. A character is just a symbol For example, there are 26 characters in the English language. Computers are not concerned with humans, they are dealing with numbers (binary). Even if you can see characters on your computer, they are stored and interpreted externally as a mixture of 0’s and 1’s.

The transformation of characters to numbers is called encoding, and the reverse process is decoding. ASCII and Unicode are some of the most common encoding used.

Example:

my_string = ‘Hello’

Please note in Python programming language, Strings can be created by enclosing characters inside a single quote or double-quotes or a triple quote.

### Built-in Strings Methods in Python

#### Must-Know String Functions

 Function Description format() It’s used to create a formatted string from the template string and the supplied values. split() It is used to split a string into the list of strings based on a delimiter. join() It is used to returns a new string that is the concatenation of the strings in iterable with string object as a delimiter. strip() It is used to trim whitespaces from the string object. format_map() It is used to returns a formatted version of the string using substitutions from the mapping provided. upper() It is used to convert a string to uppercase in Python. lower() It is used to convert a string in lowercase. replace() It is used to create a new string by replacing some parts of another string. find() It is used to find the index of a substring in a string. translate() It is used to returns a new string with each character in the string replaced using the given translation table.

### Escape Sequences in Strings

If we want to print a text such as -he said, “I am learning Python?”- we can’t use single quotes or double-quotes. This will result in SyntaxError as there are single and double quotes in the text itself.

However, we can print a quoted text in a string in Python by using a triple quote.

### Triple-Quoted Strings

Example:

`print('''She said, "I am learning Python?"''')`

### Raw Strings

If we want to print a text including escape seqquence like \newline. To do this, r or R can be put before the string. This means that it is a raw string and that any escape sequence within it is ignored.

Example:

`print(r"This is \n a string with escape sequence")`