Getting started with Python--data structure exercises

Source: Internet
Author: User

2015.9.7

A=[11,22,24,29,30,32]

1) Insert 28 into the end of List A

a=[11,22,24,29,30,32]a.append ()

2) Insert 57 after 29

A.insert (4,57)

3) Sort a list elements from small to large

A.sort ()

4) Change the first element of List A to 6

A[0]=6

5) Delete Element 32

A.pop (-1)
Del A[-1]

b=[1,2,3,4,5]

1) Output The following results in 2 ways:

[1,2,3,4,5,6,7,8]

b=b+[6,7,8]
B.extend ([6,7,8])

2) Return the result using the 2 methods of the list: [5,4]

Print B[-1:-3:-1]
c=[]c.append (B.pop ()) C.append (B.pop ())

3) Determine whether 2 is in the B list

If 2 in B:    print ' yes '

Cond...

Getting started with Python--data structure exercises

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.