List: Create a job scoring list by the string, make and delete changes to query the statistical traversal operation. For example, query the first 3 points subscript, statistics 1 points of the number of students, 3 points of the number of students and so on.
S=list (' kkkkk ') S.insert (3,2) s.pop (3) s[6]=1print (s) print (' The position of the first 1 is: ', S.index (' 1 ')) X=0y=0for I in range (len (s)): if s[i]== ' 3 ': x=x+1 if x==1: y=iprint (' The number of three points is: ', X, ', ' the first three-point position is: ', y) print (' Two-count: ', S.count (' 2 '))
Dictionary: Establish the student's academic grade dictionary, do the additions and deletions to check the traversal operation.
>>> dic=dict (Zip ([1,2,3],[' 98 ', ' + ', ') ') >>> dic{1: ' 98 ', 2: ' 3 ', ' + '}>>> dic2={4: '}>>> ' dic.update (dic2) >>> dic{1: ' 98 ', 2: ' 3 ', ' 4 ', '}>>> Dic.pop ' (2) ' >& ' Gt;> dic{1: ' 98 ', 3: ' 88 ', 4: ' 95 '}
>>> dic{1: ' 3 ', ' 4: '}>>> del dic[3]>>> dic{1: ' + ', ' 4: '}>>> dic[1]= ' ' Dic{1 ' >>>: ' + ', 3: '}>>> ', 4: ' Dic{1 ': ' 98 ', 3: ' ', ' 4: ' '}>>> ' (4) ' Up ' ;>> dic.get (5, ' no ') ' No '
>>> dic[4] ' Dic.keys ' >>> dict_keys ([1, 3, 4]) >>> dic.values () dict_values ([' 98 ', ' 88 ', ' ) >>> Dic.items () dict_items ([1, ' 98 '), (3, ' '), (4, ' up ')]) dict
A list, a tuple, a dictionary, a collection of traversal.
S=list (' 456132798 ') t=set (' 4561327489 ') c={' xiaoming ': ' 1 ', ' Little Red ': ' 3 ', ' Little Wah ': ' 2 '}x= (1, 2, 3, 4, 5) print (' The traversal of the list is: ', end= ') for I in S: Print ( i,end= ") print (' The traversal of the progenitor is: ', end= ') for I in X: print (i,end=") print () print (' Dictionary key Traversal is: ', end= ") for I in C: print (i,end= ') print () print (' Dictionary value traversal is: ', end= ') for I in C.values (): Print ( i,end=") print () Print (' array traversal: ', end= ') for I in X: print (i,end= ")
"' Download an English lyrics or article, count the number of occurrences of the word, will all,.?! Replace with a space to convert all uppercase letters to lowercase. ' sr= ' Insecuredon ' t know what foryou ' re turning heads through the Doordon ' t need make-upto cover upbeing the WA Y that's enougheveryone else in the the-the-the-the-iteveryone else but Youbaby-up my-world-like nobody El Sethe-the-you-flip your hair gets me overwhelmedbut when you're smile at the ground it ain ' t hard to tellyou don ' t know Oh ohyou don ' t know you ' re beautifulif only if you saw what I can seeyou ' ll understand why I want do desperatelyright now I ' m looking at your and I can ' t believeyou don ' t know Oh!ohyou don ' t know you ' re beautiful Oh Ohthat's what's Makes you Bea Utifulso C-come Onyou got it wrongto prove I ' m, right ' print (' Sr.count (') ') for I in SR: sr=sr.replace (', ', '/t ')
sr=sr.replace ('! ', '/t ') sr=sr.replace ('? ', '/t ') print (SR) for I in SR: Sr=sr.upper () print (SR)
python-combined Data class