Python Basic 02 Base data type

Source: Internet
Author: User

Simple data types and assignments

Variables do not need to be declared

Python variables do not need to be declared, you can enter directly:

>>> A = 10

Then your memory has a variable a, its value is 10, and its type is an integer (integer). You don't have to make any special statements until then,

The data type is automatically determined by Python.

>>>print (a)

>>>print (Type (a))

Then there will be the following output:

10

<class ' int ' >

Here, we learned a built-in function type () to query the type of the variable.

Reclaim variable names

If you want a to store different data, you do not need to delete the original variable can be directly assigned value.

>>>a = 1.3

>>>print (A,type (a))

will have the following output

1.3<class ' float ' >

We see another use of print, that is, printh followed by multiple outputs, separated by commas.

Basic data types

a=10 # int Shaping

a=1.3 # float Floating point

A=true # Truth (true/false)

A= ' hello! ' #字符串 string can also be enclosed in double quotation marks

The above is the most commonly used data types, in addition to fractions, characters, complex numbers and other types, interested can learn.

Summarize

Variables do not need to be declared, they do not need to be deleted and can be recycled directly.

Type (): Query data type

integers, floating-point numbers, Boolean values, strings

Python Basic 02 Base data type

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.