02python_ Data types

Source: Internet
Author: User

Python numeric type, number, string, Ganso, list, dictionary

Boolean: Flase, Ture (judging true and false)

Long Integer/Shaping:

Python can handle integers of any size, including, of course, negative integers, which are represented in the program in the same way as mathematically, for example: 1,100,-8080,0, etc.

Floating point number

Floating-point numbers, which are decimals, are called floating-point numbers because, when represented by scientific notation, the decimal position of a floating-point number is variable, for example, 1.23x109 and 12.3x108 are equal. Floating-point numbers can be written in mathematical notation, such as 1.23,3.14,-9.01, and so on. But for very large or very small floating-point numbers, it must be expressed in scientific notation, the 10 is replaced with E, 1.23x109 is 1.23e9, or 12.3e8,0.000012 can be written 1.2e-5, etc.

String:

strings are arbitrary text enclosed in ' or ', such as ' abc ', ' XYZ ', and so on. Note that the ' or ' itself is only a representation, not a part of the string, so the string ' abc ' only a,b,c these 3 characters. If ' itself is also a character, then you can use "", such as "I m OK" contains the characters are I, ', M, space, o,k these 6 characters.

List

One of the data types built into Python is the list: lists. A list is an ordered set of elements that can be added and removed at any time.

Tuple another ordered list is called tuples: tuple. The tuple and list are very similar, but the tuple cannot be modified once initialized classmates = (' Michael ', ' Bob ', ' Tracy ') Now, classmates this tuple cannot be changed, and it has no append (), The Insert () method. Other methods of acquiring elements are the same as lists, and you can use classmates[0],classmates[-1] normally, but you cannot assign them to another element. What is the meaning of immutable tuple? Because the tuple is immutable, the code is more secure. If possible, you can use a tuple instead of a list as much as possible. The trap of a tuple: when you define a tuple, the elements of the tuple must be determined when defined, such as: T = (1, 2) print T If you want to define an empty tuple, you can write ()

Dictpython built-in dictionary: dict support, Dict full name dictionary, also known as map in other languages, using key-value (Key-value) storage, with extremely fast search speed

02python_ Data types

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.