Python data structure

Source: Internet
Author: User

Data processing function: Round (), four six into the five, floor () rounding down, ceil () rounding up,//division and rounding down, mix () Take the Minimum, Max () to take the maximum value,
The return value of the binary function is a string: Bin () takes binary, Oct () takes eight, Hex () takes 16 binary,
List of lists: an orderly line of troops, indexable, linear data structures, denoted by [], the list is mutable,
List increment, insert element: Append element to append list, extend () appends elements of an iterator object
List Delete element: Remove (value) finds the first value that matches value from left to right, removes the element, reverse (): Reverses the list element, sort: Sorts the list elements, the default ascending, copy () copies, random number: randomness module, Choice (seq) randomly picks an element from an element of a non-empty sequence,
Tuple tuples: A set of sequential elements, denoted by (), tuples are immutable, support indexes, are read-only, so the increment, change, and delete methods are not,
Bubbling method: Belongs to the Exchange sort, 22 compare size, swap position, the result is divided into ascending and descending order,
A simple example:
Nums = [1,9,8,5,6,7,4,3,2]
length = Len (nums)
For I in range (length):
For j in Range (Length-1-i):
If NUMS[J] > nums[j+1]:
TMP = Nums[j]
NUMS[J] = nums[j+1]
NUMS[J+1] = tmp
Print Yang Hui triangle:
Print (Nums)
n = 12
row = [1]N
For I in range (n):
offset = N-i
z = 1
For j in range (1, i//2+1):
val = z + row[j]
z = row[j]
ROW[J] = val
If I! = 2
J:
Row[-j-offset] = val
Print (row[:i+1])
String: A sequence of characters consisting of a set of characters, a sequence of characters that are quoted in single, double, and triple quotes, is immutable, supports indexing, can iterate, "string". Join joins an iterative object, using string as a delimiter, String splitting: Split: Splits the string into strings by delimiter and returns the list, from left to right, partition: divides the string into 2 segments by delimiter, returns the tuple of 2 segments and separators, right-to-left, Len () returns the length of the string, that is, the number of characters, count () count the number of occurrences of the substring,
Bytes: Immutable byte sequence, ByteArray: variable, byte array,

Python data structure

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.