Basic data types for Python

Source: Internet
Author: User

In the Python language, variables do not need to be declared, each variable must be assigned before it is used, and the variable will not be created until the value is assigned.

In Python, a variable is a variable he has no type, and the type we call refers to the type of the variable in the in-memory object.

The equals sign (=) is used to assign a value to a variable.

The left side of the equals sign (=) operator is a variable name, and the right side of the equals sign (=) operator is the value stored in the variable.

For example:

counter = # integer variable

  miles = 1000.0   # floating-point variable

Name = "runoob" # string

< Span class= "Hl-code" > < Span class= "Hl-identifier" > multiple variables assigned

< Span class= "Hl-code" > < Span class= "hl-comment" >     python allows you to assign values to multiple variables at the same time

< Span class= "Hl-code" > < Span class= "hl-comment" >                     a = B = C =1 / span>

Creates an integer object with a value of 1 and three variables allocated to the same memory space.

a, b  ,   c  =   1   Span class= "PLN" > 2     "3"  
Two Integer objects 1 and 2 are assigned to variables A and B, the string object "3" is assigned to the variable C

python3 there are six standard data types in Python 2 has only 5 standard data types, 3 adds a collection:

Number
String string
List
Tuple ganso
Sets Collection
Dictionary dictionary

Basic data types for Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.