Case Study

姓名: 学号:

请注意以下几点:

  1. Write a program to read the file Harry_Potter.txt and count the number of words in this file. Then, create and write the number of words in another .txt file named 'Count_Words' (You do not have to submit the file you generate.) Download the Harry Potter.txt file.

  2. Given 3 points on a 2D plane, design a function to do the following:

    • determine whether 3 points lie on a straight line;

    • if they do not lie on a straight line, draw a triangle with those points. (please import matplotlib) Note that the straight line or one of the triangle's edges may be perpendicular to the x-axis. Please take this possibility into account. The following shows the execution of your program.

    示例图片链接

  3. There is a midterm.csv file about the grading results of a course's midterm exam. The first row presents the header. Then, each row presents a student's enrolled name and his or her score. Write a program to read the file and collect all the scores in a list (without the header row!) Download the midterm.csv file. Classify those scores according to the criteria given by question 2 in Problem Set 1. Then, draw a histogram with plotly for ranks A, B, C, D, F.

  4. There is a data set regarding my consumption information in canteens of SUFE in April 2018, Download the data.json file. By Plotly or Matplotlib, please draw a histogram illustrating the frequencies of my visiting different canteens.

  1. With the data in Question 4, draw a line chart to illustrate my daily consumption in April 2018.

  2. The file athlete_events.csv contains 271116 rows and 15 columns. This is a historical dataset on the modern Olympic Games, including all the Games from Athens 1896 to Rio 2016. Each row corresponds to an athlete competing in an Olympic event (athlete events). The columns are explained in the following table:

    ID: Unique number for each athleteName: Athlete's name
    Sex: M or FAge: Integer
    Height: in centimetersWeight: In kilograms
    Team: Team nameNOC: National Olympic Committee 3-letter code
    Games: Year and seasonYear: integer
    Season: Summer or WinterCity: Host city
    Sport: SportEvent: detailed event
    Medal: Gold, Silver, Bronze, or NA 

    Please pick any column(s) in the data set to draw a figure from which you can draw meaningful conclusions. Download the athlete_events.csv file