What are the built-in types of 6 sequences in Python python?

Source: Internet
Author: User

This section focuses on the following issues:

1. What are the built-in types of 6 sequences in Python?

2. What are the similarities and differences between lists and tuples?

1. What are the built-in types of 6 sequences in Python?

Python contains 6 built-in sequences, which are lists, tuples, strings, Unicode strings, buffer objects, and Xrange objects. The operations common to a sequence include: index, length, combination (sequence addition), repetition (multiplication), Shard, check member, Traverse, minimum, and maximum values.

2. What are the similarities and differences between lists and tuples?

Python has 6 built-in types of sequences, but the most common are lists and tuples.

Lists and tuples are similar, with the following aspects:

Same point:

1, all have the characteristics of the sequence, can be a sequence of common operations;

2, usually used in parentheses, and the elements in parentheses appear as comma-separated values, data items do not need to have the same type;

3, all contain built-in functions Max, Min, Len;

4, can be converted to each other;

Similarities and differences point:

1. Define Different

1) The list is enclosed in square brackets.

2) tuples are enclosed in parentheses.

2. Is it possible to modify

1) list can be modified

2) tuples cannot be modified

3. Conversion Mode

1) List of tuples: tuple (seq)

2) Tuples to lists: list (seq)

4. Whether the built-in method is included

1) The list provides 11 built-in methods List.append (obj), list.count (obj), list.extend (seq), List.index (obj), List.insert (index, obj), List.pop ([Index=-1]]), List.remove (obj), List.reverse (), List.sort (Cmp=none, Key=none, Reverse=false), List.clear (), List.copy ();

2) tuples do not provide built-in methods

What are the built-in types of 6 sequences in Python python?

Related Article

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.