WeChat Official Account: Creative Diary
Send: Python Experiment
Get a complete and clear report, source code and other resources
A few days ago, I found a giant bull's artificial intelligence learning e-book. It is easy to understand, humorous, and has no ads. I can't help but share it with everyone.(click to jump to artificial intelligence learning materials)
One.Experiment purpose
1.Learn about the 3 basic composite data types.
2.Understand list concepts and master the use of lists in Python.
3.Understand dictionary concepts and master the use of dictionaries in Python.
4. Use jieba library for Chinese word segmentation and text word frequency statistics.
Second.Knowledge points
1. General map of knowledge points
Three.Experiment content and steps
1. Use the list to realize the game of rock-paper-scissors.Please complete the program and submit.
Please think: Can winList be implemented using tuples?Children's shoes, try it out!
2. Use dictionary to realize personal information query program of heroes.Please complete the program and submit.
Please think: How to modify the program so that the user only exits the program when he enters "exit"?Ladies and gentlemen, brighten up your means!Hint: Refer to the rock-paper-scissors game in 1.
The program execution effect is as follows:
3. Use jieba library to segment Li Zhiyi's "Fortune Teller", according to the following requirementsProgramming.
(1) Use the jieba library to perform word segmentation on Li Zhiyi's Divination Operator, and check the word segmentation results.
(2) Count each word and saveinto the dictionary type counts.View the contents of counts.
(3) According to the number of occurrences of the word from high to highlow ranking.Because the dictionary type is unordered and cannot be sorted, convert the counts to a list type (see "Details of the use of the sort method of lists in python" for the knowledge of list sorting).View sorted results.
(4) In order to enhance the readability of the sorted results, useformat adjusts the format of the output.
4. "Dream of Red Mansions" character statistics.Refer to the "Romance of the Three Kingdoms" character appearance statistics program in the textbook, write a program to count the top 20 most played characters in "A Dream of Red Mansions", and submit it.Here is the reference answer.(For the source code, please refer to WeChat public account download)
(Jia Baoyu, 3908), (Wang Xifeng, 1611), (Jia Mu, 1429), (Lin Daiyu, 1291), (Mrs. Wang, 1061), (Xue Baochai, 929), (Xiren, 745), (Jia Lian, 688), (Ping’er, 602), (Jia Zheng, 523), (Aunt Xue, 455), (Tanchun, 437), (Yuanyang, 423), (Shi Xiangyun, 412), (Qingwen, 336), (Jia Zhen, 299), (Grandma Liu, 288), (Zijuan, 288), (Mrs. Xing, 287), (Xiangling, 264)