Detailed description of the application solution for creating Python Data Structures

Source: Internet
Author: User

This article mainly introduces the Python Data Structure Code and the Python Data Structure in practical application related operation solutions. The following describes the specific content of the article, if you are interested in the content related to Python data structures, you can read the article to learn about it.

1. list: Variable Assignment Method: shoplist = ['apple', 'mango', 'carrot', 'bana']

2. tuples array: variable value assignment method: zoo = ('Wolf ', 'elephant', 'penguin ')

3. dictionary dict: Variable assignment mode: d = {key1: value1, key2: value2}

4. sequence: the list, tuples, and strings are all sequences.

(1) index OPERATOR: gets a character of an element or string in the list/tuples.

(2) slice OPERATOR: gets a slice of a sequence, continuous element/Character

(3) eg:

 
 
  1. name = ’swaroop’  
  2. print ‘characters 0 is’, name[0]    

S ', index operator, similar to C #

 
 
  1. print ‘characters 1 to 3 is’, name[1:3] 

'Wa 'slice operator, similar to the Substring method in C #

In fact, Python contains a lot of content. For example, Python is different from the traditional interpreted scripting language. It will be compiled into bytecode during the first execution, then run the code. NET's DLR is a bit similar to Java's virtual machine. In short, it is to convert code into a way closer to machine code, which can improve performance.

Many people say that C # and Java are working languages, while Python and Ruby are weekend languages. In fact, they all communicate with each other and learn more to broaden their horizons, when agile development is so popular, selecting one of them is also a guarantee, isn't it? If you are familiar with Python, I believe you will like it.


-
 

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.