python data structure Exercises

Problem 1

List a = [11,22,24,29,30,32]

1, 20 is inserted into the end of the list

2, is inserted after the element 29 in the element 57

3, the element 11 is modified to 6

4, remove elements 32

5, from small to large to list

Problem 2

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

1, the following results are output in two ways

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

2, returns the result list by two methods: [5,4]

3, 2 to determine whether the list

Problem 3

b = [23,45,22,44,25,66,78]

The following exercises complete list derived by the formula:

1, generates a list of all odd composition

2, output: [ 'the content 23', 'the content 45']

3, output: [25,47,24,46,27,68,80]

4, by generating a list of range and a method of deriving a list of:

[11,22,33]

Problem 5

Known tuple: a = (1,4,5,6,7)

1, it is determined whether or not the element 4 in the tuple

2, the element 5 is modified to 8

Problem 6

Known collection: setinfo = set ( 'acbdfem') and set finfo = set ( 'sabcdef')

1, add the string objects 'abc' to the collection setinfo

2, delete the collection members inside the m setinfo

3, find the intersection of two sets of union and

Problem 7

Following the completion of a small student management system with a dictionary way.

1, the students are the following attributes: name, age, test scores include: language, mathematics, English.

For example, the definition of two students:

Name: Li Ming, aged 25, test scores: 75 language, math 80, English 90

Name: Zhang Qiang, aged 24, test scores: 89 language, math 81, English 80

2, the students add a Python course grade, Li Ming 60 points, 80 points Zhang Qiang

3, Zhang Qiang, the math scores of 81 into 89 points

4, delete data Li's age

5, Zhang Qiang course scores of students in accordance with the output from low to high order

6, outside the city to delete the student's property, there is no return string beijing

 

Published 18 original articles · won praise 3 · views 20000 +

Guess you like

Origin blog.csdn.net/wangxiaolin1992/article/details/90230423