Python basics 02 Basic Data Types

Source: Internet
Author: User

Author: vamei Source: http://www.cnblogs.com/vamei welcome reprint, please also keep this statement. Thank you!

 

Simple data type and value assignment

1) variables do not need to be declared

Python variables do not need to be declared. You can enter them directly:

>>> A = 10

Then there is a variable A in your memory. Its value is 10 and its type is integer ). Before that, you do not need to make any special declaration, but the data type is automatically determined by python.

>>> Print

>>> Print type ()

The following output is displayed:

10<Type 'int'>

 

Here, we will learn a built-in FunctionType ()To query the type of a variable.

2) reclaim variable names

If you want a to store different data, you can directly assign values without deleting the original variables.

>>> A = 1.3

>>> Print a, type ()

The following output is displayed:

 

 
1.3 <type 'float'>

 

We can see thatAnother usage of print, That is, print followed by multiple outputs, separated by commas.

3) Basic Data Types

A = 10# Int integer

A = 1.3# Float floating point number

A = true# True Value (true/false)

A = 'Hello! '# String

The above is the most common data type. Double quotation marks can also be used for strings.

(In addition, there are scores, characters, plural numbers, and other data types. If you are interested, you can learn)

 

Summary:

Variables do not need to be declared or deleted. They can be recycled directly.

Type (): query data type

Integer, floating point, true value, string

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.