u1s1,这门课的assignment还是有点难度的,特别是assigment4(哀怨),放给大家参考啦~
有时间(需求)就把所有代码放到github上(好担心被河蟹啊)
相关链接:
Coursera | Introduction to Data Science in Python(University of Michigan)| Quiz
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment1
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment2
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment3
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment4
CSDN链接:
Coursera | Introduction to Data Science in Python(University of Michigan)| Quiz答案
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment1
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment2
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment3
Coursera | Introduction to Data Science in Python(University of Michigan)| Assignment4
assignment1挺简单的,就是个入门。
Assignment 1
For this assignment you are welcomed to use other regex resources such a regex “cheat sheets” you find on the web.
Before start working on the problems, here is a small example to help you understand how to write your own answers. In short, the solution should be written within the function body given, and the final result should be returned. Then the autograder will try to call the function and validate your returned result accordingly.
1 | def example_word_count(): |
Part A
Find a list of all of the names in the following string using regex.
Code
1 | import re |
1 | assert len(names()) == 4, "There are four names in the simple_string" |
结果
Part B
The dataset file in assets/grades.txt contains a line separated list of people with their grade in
a class. Create a regex to generate a list of just those students who received a B in the course.
Code
1 | import re |
下面这个也可以。其实都可以,两个的区别是是否包含成绩。
1 | def grades(): |
1 | assert len(grades()) == 16 |
结果
包含成绩:
不包含成绩:
Part C
Consider the standard web log file in assets/logdata.txt. This file records the access a user makes when visiting a web page (like this one!). Each line of the log has the following items:
- a host (e.g., ‘146.204.224.152’)
- a user_name (e.g., ‘feest6811’ note: sometimes the user name is missing! In this case, use ‘-‘ as the value for the username.)
- the time a request was made (e.g., ‘21/Jun/2019:15:45:24 -0700’)
- the post request type (e.g., ‘POST /incentivize HTTP/1.1’ note: not everything is a POST!)
Your task is to convert this into a list of dictionaries, where each dictionary looks like the following:
1 | example_dict = {"host":"146.204.224.152", |
Code
1 | import re |
1 | assert len(logs()) == 979 |
结果
部分:
大家其他还有需要的就在评论留言哦 :) 欢迎讨论分享~