Python Workbooks--4th Chapter list

Source: Internet
Author: User

After-school exercises:

1.[] is an empty list

2.

1 ' Hello ') Wrong, should be: spam[2] = ' Hello '

3.[' d '] ' d '

4.[' d '] ' d '

5.[' A ', ' B ']

6.1

7.[3.14, ' cat ', One, ' cat ', True, 99]

8.[3.14, one, ' cat ', True]

9. Connect +, copy *

The 10.inset () method allows you to specify a position insertion

11.del and remove () methods

12.

13. The list can be modified, the meta-ancestors can not modify

14. ((42)) (42,)

15.tuple (); list ()

16. References

17.copy.deepcopy () can copy the list contained in the original variable to copy all lists in the list

Practical projects

4.10.1 Comma Code

1Spam = ['Apples','Bananas','Tofu','Cats','fishes']2 3 4 defLianjie (somelist):5result ="'6      forIinchRange (len (somelist)-1):7Result + = (Somelist[i] +',')8Result + = (' and'+ somelist[-1])9     Print(Result)Ten  OneLianjie (spam)

4.10.2-Character metalized grid

1Grid = [['.','.','.','.','.','.'],2['.','0','0','.','.','.'],3['0','0','0','0','.','.'],4['0','0','0','0','0','.'],5['.','0','0','0','0','0'],6['0','0','0','0','0','.'],7['0','0','0','0','.','.'],8['.','0','0','.','.','.'],9['.','.','.','.','.','.']]Ten  One  forJinchRange (6): A      forIinchRange (9): -         Print(Grid[i][j], end="')#print each element in a column -     Print(Grid[i][j])#finish a column and lay a column

Python Workbooks--4th Chapter list

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.