Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What data types are there in python?
What data types are there in python?
The data types in python are integer, long integer, floating point, string, Boolean, list, tuple, word typical and set.

Data type is the basic attribute of every programming language. Only by giving the data a clear data type can the computer process and calculate the data. Therefore, it is very necessary to use data types correctly. Different languages have similar data types, but the specific representation methods are different. The following data types are commonly used in Python programming:

1. Number type

Python's number types mainly include int (integer), long (long integer) and float (floating point), but there is no long type in Python3.

Int (integer)

On a 32-bit computer, the number of digits of an integer is 32, and the range of values is-231~1,that is,-2147483648 ~ 214748364; On a 64-bit system, the number of digits of an integer is 64, and the range of values is -263~263- 1, that is, 922337203685475808 ~ 92237203685475807.

Long (long integer)

Python long integer does not specify bit width, but due to the limited memory of the machine, it is impossible to use long long integer value indefinitely.

Float (floating point type)

Floating-point type is a number with a decimal point, and its precision is related to the machine.

Complex (complex)

Python also supports complex numbers, which are composed of real and imaginary parts and can be represented by a+bj or complex numbers (a, b). The real part A and imaginary part B of a complex number are both floating-point types.

2. Line

In Python, all quoted characters are considered as strings, which can be declared in three ways: single quotation mark, double quotation mark and triple quotation mark; There are two data types of strings in Python, namely str type and unicode type. Str type adopts ASCII encoding, which cannot represent Chinese, and unicode type adopts unicode encoding, which can represent any character, including Chinese and other languages.

3. Boolean type

Like other programming languages, Python Boolean types are also used for logical operations and have two values: True (true) and False (false).

List

List is the most commonly used data type in Python. You can put any data type into a collection, and you can create, find, slice, add, modify, delete, cycle and sort the collection.

5. Tuples

A tuple, like a list, is a sequence. Unlike lists, tuples cannot be modified. Tuples are marked with "()", and internal elements are separated by commas.

6. Dictionary

Dictionary is a collection of key-value pairs, and it is the most flexible built-in data structure type in Python except list. List is an ordered collection of objects, while dictionary is an unordered collection of objects.

put together

A set is an unordered and non-repetitive data combination, which has two main functions, namely, deduplication and relational testing.

Recommended course: Python3 Machine Learning Quick Start (Dark Horse Programmer)