Introduction to basic data types and variable declarations in the basic python tutorial

Source: Internet
Author: User
This article mainly introduces the basic data types and variable declaration in the basic python tutorial. it first introduces some knowledge about variable declaration and then lists the most common basic data types, for more information, see Variable does not need to be declared

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

The code is as follows:


>>> 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.

The code is as follows:


>>> Print

>>> Print type ()


The following output is displayed:

The code is as follows:


10

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

Reclaim variable name

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

The code is as follows:


>>> A = 1.3

>>> Print a, type ()


The following output is displayed:

The code is as follows:


1.3

We can see another usage of print, that is, print is followed by multiple outputs, separated by commas.

Basic data type

The code is as follows:


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.