Home >Backend Development >Python Tutorial >What data types are there in python

What data types are there in python

silencement
silencementOriginal
2019-06-11 11:26:1533284browse

In a Python program, each data is an object, and each object has its own type. Different types have different operation methods. Using the unique operation methods of built-in data types, you can complete a lot of work faster.

What data types are there in python

Some basic data types in python, such as: integer (number), string, tuple, list, dictionary and Boolean type. As the learning progress deepens, everyone will come into contact with more and more interesting data types. Beginners of Python can just understand these types first when getting started.

Corresponding symbols of python's basic built-in data types

1. Integer type - int - number

Python has 5 number types, the most common is the integer type, and the int python method is very practical. For example: 1234, -1234

2. Boolean type - bool - represented by the symbol ==

The Boolean type is a special python number type, it only has two types: True and False A value, which is mainly used for comparison and judgment, and the result is called a Boolean value.

For example:

3==3 给出True,3==5给出False

3) String - str - represented by ' ' or " "

For example:

'www.iplaypy.com'或者"hello"

4) List - —list——Use [ ] symbol to represent

, for example:

[1,2,3,4]

5) Tuple——tuple——Use ( ) symbol to represent

, for example:

('d',300)

6) Dictionary - dict - represented by { } symbol

For example:

{'name':'coco','country':'china'}

Which of the basic data types in Python are mutable and which are immutable

Python variable data types: list list[ ], dictionary dict{ }

Python immutable data types: integer int, string str' ', tuple tuple()

The above is the detailed content of What data types are there in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn