diff --git "a/source/_posts/2019-07-30-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\257\276-lecture8notes37.md" "b/source/_posts/2019-07-30-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\257\276-lecture8notes37.md" new file mode 100644 index 00000000..56eb0532 --- /dev/null +++ "b/source/_posts/2019-07-30-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\257\276-lecture8notes37.md" @@ -0,0 +1,58 @@ +--- +title: 1901030012-MIT-Python课-lecture 8 +date: 2019-07-30 03:01:57 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号:1901030012 +- 学习内容:MIT第8课视频文稿p7-8及幻灯片p12-13 +- 学习用时:67min Notes no.: Day37 + +### 学习笔记 + +1. *assigned vs. equal to* +> So now we have sort of a nice class. It’s very simple, but we can start actually creating coordinate objects. So when you create coordinate objects, you’re creating instances of the class. +> +> So this line here, C is **equal to** coordinate 3,4, is going to call the init method. It’s going to call the init method with x is **equal to** 3 and y is **equal to** 4. + +Cat notes: +Here when prof. “read” this piece of codes, “=” read as “equal to” however be aware of its actual specific meaning in Python, “=” means to assign or passing it all the variables, “==” means to check operational “equal to”, and also bear in mind about “!=” —not equal to, when using in arguments to demonstrate boolean operation. + +2. *dot notion* +We can access the data attributes using this dot notation and we’ve seen that before, right? +When we’ve worked with lists we’d say something like, L dot append, right, when we create a list. So the same dot notation can be used with your own objects in order to access data attributes. So here, this is going to print 3 because the x value for object C is 3, and the next line, print origin x is going to print 0 because the x value for the object origin is 0. + +3. *init method* +We have to find the init method so we have a way to **create** objects when we use the class. And then we can **access the data attributes**. But that’s kind of lame, right, because there isn’t anything cool we can do with it. + +4. *add more methods* +Remember methods are going to be **procedural attributes** that allow us to **interact with** our object. + +Methods are **like** functions **except** that there’s a couple of differences which you’ll see in a moment. + +eg: “distance” +So notice this method is pretty much like a function, right? You have DF, some name, it takes in parameters. It does some stuff and then it returns a value. The **only difference** is the fact that you have a **self** here as the **first thing** and the fact that you **always** have to be conscious about **whose** data attributes **you’re accessing**. So you have to use the dot notation in order to **decide** whose data attributes you **want access**. So we’ve defined the method here, distance. + +5. *Euclidean distance formula* +So here I’m going to just implement the Euclidean distance formula, which is x1 minus x2 squared, plus y1 minus y2 squared, and square root of all that. So that’s what I’m doing inside here. + +``` +class Coordinate(object): + def __init__(self, x, y): + self.x = x + self.y = y + def distance(self, other): + x_diff_sq = (self.x - other.x) ** 2 + y_diff_sq = (self.y - other.y) ** 2 + return (x_diff_sq + y_diff_sq) ** 0.5 +``` +> Other than self and dot notation, methods behave like functions (take params, do operations, return) + +6. **我看到的** +时间和实践是最好的朋友,当和最好的朋友在一起的时候,人是真诚、充实、无需谎言的。 +我们的Camp给我们提供了默认的methods来让我们和自己最好的朋友尽可能的相处,我们也许还不知道default的缘由,但是,能使用到这些methods然后逐渐地通过一步一步的迈进能看到default以及缘由,我们自己就可以create我们的methods,与别人交流,供别人使用,我觉得我这次真的看到了**希望**。下一步是,build it up。 +感谢营友们的美好,这个世界有你们真好!!! +加油! \ No newline at end of file diff --git "a/source/_posts/2019-08-02-1901030012-\350\207\252\345\255\246\346\225\260\346\215\256\350\220\245-\350\207\252\346\210\221\344\273\213\347\273\215.md" "b/source/_posts/2019-08-02-1901030012-\350\207\252\345\255\246\346\225\260\346\215\256\350\220\245-\350\207\252\346\210\221\344\273\213\347\273\215.md" index 4eef654d..7f8652e6 100644 --- "a/source/_posts/2019-08-02-1901030012-\350\207\252\345\255\246\346\225\260\346\215\256\350\220\245-\350\207\252\346\210\221\344\273\213\347\273\215.md" +++ "b/source/_posts/2019-08-02-1901030012-\350\207\252\345\255\246\346\225\260\346\215\256\350\220\245-\350\207\252\346\210\221\344\273\213\347\273\215.md" @@ -16,7 +16,9 @@ categories: '自我介绍' ### 自我介绍 + 1. 自我介绍: + 本人叫王露萩,朋友都叫我Cat。中国和美国加州执业律师。实际心理年龄只有4岁8个月左右,对世界开启了好奇心。我可以使用中文、英文。在学习使用Python和日文。 2. 为什么想学习数据分析: @@ -31,4 +33,4 @@ categories: '自我介绍' 14天Python入门营毕业,MIT6.0001课程学习文稿到lecture8文稿的p12.(练习题做到 psets 1 part A) 4.2 *疑惑*: 4.2.1 语言概念定义的关联,范畴,暂时还没有梳理明白; - 4.2.2 看见数字和图表内心深处阴影面积暂时还是会产生巨大压力影响自己的学习动作变形。 + 4.2.2 看见数字和图表内心深处阴影面积暂时还是会产生巨大压力影响自己的学习动作变形。 \ No newline at end of file diff --git "a/source/_posts/2019-08-06-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\257\276-lecture8notes38.md" "b/source/_posts/2019-08-06-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\257\276-lecture8notes38.md" new file mode 100644 index 00000000..c0d9dd85 --- /dev/null +++ "b/source/_posts/2019-08-06-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\257\276-lecture8notes38.md" @@ -0,0 +1,58 @@ +--- +title: 1901030012-MIT-自学 lecture8 +date: 2019-08-06 21:50:00 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容: MIT第8课视频文稿p9-10 slide p12-16 +- 学习用时: 66min Notes no.: Day38 + +### 学习笔记 + +1. *convention* +So by convention, it's a lot easier to do the one on the left. +And as I mentioned, Python implicitly says, if you're doing the one on the left, you can call this method on a particular object and it's going to look up the type of the object and it's going to essentially convert this on the left to the one on the right. +def distance(self, other): + *code here* + +|**Using the class:**| | +--|--| +**- [ ] conventional way** | **- [ ] equivalent to** +c = Coordinate(3,4) | c = Coordinate(3,4) +zero = Coordinate(0,0) | zero = Coordinate(0,0) +print(c.distance(zero)) | print(Coordinate.distance(c, zero) + + +object to call method on *c*, name of method is *distance* and parameters not including *self* (*self* is implied to be *c*). + +2. *informative debugging tool--str method* +So if you create a coordinate object, C is equal to coordinate 3, 4, right? That's what we've done so far. If you print C, you get this funny message. +Very uninformative, right? It basically says, well, C is an object of type coordinate at this memory location in the computer. Which is not what you wanted at all, right? Maybe you wanted to know what the values for x and y were. That would be a lot more informative. So by default, when you create your own type, when you print the object of that type, Python tells you this sort of information which is not what you want. So what you need to do is you need to define your own method that tells Python what to do when you call print on an object of this type. + +> >>> c = Coordinate(3,4) +> >>> print(c)<__main__.Coordinateobject at +> 0x7fa918510488> + +- define a __str__ method for a class. +- Python calls the __str__ method when used with *print* on your class object. +- you choose what it does! Say that when we print a Coordinate object, want to show: +> print(c) +<3,4> +``` +class Coordinate(object): + def __init__(self, x, y): + self.x = x + self.y = y + def distance(self, other): + x_diff_sq = (self.x - other.x) ** 2 + y_diff_sq = (self.y - other.y) ** 2 + return (x_diff_sq + y_diff_sq) ** 0.5 + def __str__(self): + return "<" + str(self.x) + "," + str(self.y) + ">" +``` + +3. 我来实验一下啊,我怎么不能换行(据说是要空两个空格啊)呢?还有就是最最最简单的图表怎么就是搞不定呢?(不是搞不定,是眼睛无比的粗心大意,,,使劲盯着看,,,我舅说的没错,规范啊规范很重要,那就盯着盯着的不就找出来不同了)。然而,这个列表的点点是怎么输入进去的呢?!让我再纠结一会儿吧。 diff --git "a/source/_posts/2019-08-07-1901030012-\350\207\252\345\255\246\346\225\260\346\215\256\350\220\245-\344\275\234\344\270\2321\346\200\235\350\200\203\350\256\260\345\275\225001.md" "b/source/_posts/2019-08-07-1901030012-\350\207\252\345\255\246\346\225\260\346\215\256\350\220\245-\344\275\234\344\270\2321\346\200\235\350\200\203\350\256\260\345\275\225001.md" new file mode 100644 index 00000000..916caeee --- /dev/null +++ "b/source/_posts/2019-08-07-1901030012-\350\207\252\345\255\246\346\225\260\346\215\256\350\220\245-\344\275\234\344\270\2321\346\200\235\350\200\203\350\256\260\345\275\225001.md" @@ -0,0 +1,64 @@ +--- +title: 1901030012-自学数据营-作业1思考记录001 +date: 2019-08-07 01:56:09 +tags: ['数据营', '思考', '点滴'] +categories: '自学数据营' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容: 数据营学员手册+Markdown说明 +- 学习用时: 183mins Notes no.: 001 + +### 学习笔记 + +1. *我的问题* +重新看了JupterLab里的code,raw,markdown显示,突然感觉自己就是没有勇气面对和解决自己的问题:遵从规范。 + +我,骨子里,对于规范的理解存在被别人输入的偏见。而行为中实际是遵从原则和规范的。因为这样才效率,而有违自我价值观的那个部分,实质上就是宕机的主要诱因,很可能,很可能就是“我的”价值观出现了问题啊,小傻蛋。(哈哈哈哈哈摸摸脑袋。patpat,therethere) + +2. *我的解决办法尝试001* +我的问题:不知道什么是规范,由于偏见直接内植virus干扰自己对于去读规范以及不熟悉而看不懂规范的时候跳闪谎言:懂这个干嘛。well,解决这个问题: +``` +Import 许岑 as Marcus + +Import @realcaiying as Maestro + +Import @糖总总 as 糖糖 + +# 那么还是Maestro给我的必杀技啊,#fixme#这个部分的规则和规范是什么,我能知道多少,在哪儿能补充完整,先记录,不要想着一出手就成。 + +Marcus*大器免成*.SELFLEARNING(something) + +# 我舅说的分清主次,完全可以使用Marcus还有Maestro的methods来训练解决。来,请伸出猫爪子,开始吧。囫囵吞枣的先。 + +``` + +3. *拆解分析尝试001* +3.1 我们的目的好像是:去读,去实践规范,并最终能理解规范的内涵外延与历史背景。 + +3.2 主要问题是要实现action1;`action1 = 去读与去实践、使用` 而干扰action1的是behavior1; `behavior1 = 认为要搞不清楚规范的内涵外延与历史背景就不能行动了?` 但是,实际上behavior1是次要矛盾,因为即便是以要理解为目的,action1也是必要的,而且是需要足够量的action1的积累才可能最终带来目的实现的,这里面隐藏的一个变量叫做`workable_time`,这里还隐藏着另外一个`action2 == reflection1`,这里还隐藏了一个函数叫`recursion1`(我还没有想明白),这里面隐藏的一个theory叫做: +``` +[(action1*workable_time) * (action2*workable_time) ] ** (recursion1*workable_time) == [(action1*workable_time) * (reflection1*workable_time)]** +(recursion1*workable_time) +``` + +3.3 根据上述分析,不懂的部分目前看是正常的啊,是需要有效时间投入到不断熟悉的过程的。那么过程才是主吧,所以,每天要完成`action1 + action2`. 同时不放弃思考自己不明白的那些部分。 +`#fixme# why insert _ between names characters inside the variable names causing effects unexpected, how to solve it?check the guides later to fix it.` + +3.4 观察自己的actions,我不敢乱点东西,每一个步骤我都要问好几遍自己,而且最终我还是需要找别人帮我确认。但是,如果使用上面的分析,实际上只要持续进行`action1 + action2`,自我采用什么方式都可以啊。Maestro和糖糖还有Marcus都提到的 **“玩”** 。他们的玩的定义是什么,我感觉很重要。因为,这个定义或者是个函数,可能就是我的核心问题的一部分解。 + +我不敢点,因为我不知道我现在是可以玩的,玩,是需要被许可的么? + +这个问题对我而言这么重要是因为,我突然间似乎能够体会,他们说这个词是很认真地,褒义地使用的,而且,我还是觉得我不会玩这个是个很重要的问题,所以,通过行动来玩,搞清楚玩的定义对我而言很重要,这个是 **I want** 。 + +玩,自始应该是源自我自己想要干什么吧,我的问题是,我想要,这个是什么?(how pathetic I was…how lucky I have been…Cat you can do it, let us keep moving on!!!) + +想起来MIT Professor Ana Bell的[话-lecture1](ytpJdnlu9ug.pdf), 核心是:别怕哈,玩不坏,大不了关机重启嘛。 +> And I think, also, one of the big things is if you’re new to programming, you’re kind of afraid that you’re going to break your computer. And you can’t really do that just by running Anaconda and typing in some commands. +> So don’t be afraid to just type some stuff in and see what it does. Worst case, you just restart the computer. Yeah. That’s probably the big thing right there. +> I should have probably highlighted it, but **don’t be afraid**. + +综上,实际上,我们的目标是 **行动** 。 +`action1 + action2` **玩** 起吧。 diff --git "a/source/_posts/2019-08-07-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture8notes39.md" "b/source/_posts/2019-08-07-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture8notes39.md" new file mode 100644 index 00000000..70f64f50 --- /dev/null +++ "b/source/_posts/2019-08-07-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture8notes39.md" @@ -0,0 +1,55 @@ +--- +title: 1901030012-MIT-自学 lecture8 +date: 2019-08-07 23:09:20 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容: MIT第8课视频文稿p11-13 +- 学习用时: 20min Notes no.: Day39 + +### 学习笔记 + +1. *type vs. class* +If we look at coordinate as a class, if we print what coordinate is, coordinate is a class, right? +So this is what Python tells us, if we print coordinate, it's a class named coordinate. +And if we print the type of a coordinate, well that's just going to be a type. **So class is going to be a type.** _[why?]_ +So you're defining the type of an object. If you'd like to figure out whether a particular object is an instance of a particular class, you use this special function called isinstance. So if you print is instance C comma coordinate, this is going to print true because C is an object that is of type coordinate. +```# This does not make sense to me: +print(Coordinate) + +print(type(Coordinate)) + + +use isinstance() to check if an object is a Coordinate +print(isinstance(c, Coordinate)) +True +``` + +2. *The computer only do what you tell it how to, and Python too* +If you have not implemented this method and you try to add two objects of type coordinate, you're going to get an error because Python doesn't actually know right off the bat how to add two coordinate objects, right? You have to tell it how to do that. And you tell it how to do that +by implementing this special method. Same with subtract. Same with equals. +|**SPECIAL OPERATORS**| | +--|--| +*defined* | *meaning* +__add__(self, other) | self + other +__sub__(self, other) | self - other +__eq__(self, other) | self == other +__lt__(self, other) | self < other +__len__(self) | len(self) +__str__(self) | print(self) + +... and others, do whatever you'd like to do. And then you +*document* what you've *decided*. + +3. *相信自己的源头--自己的行动* +如果我没有行动,那么还是不信点滴,认为一点一滴没有那么重要,那么还是回到自己的定义里再审视,有部分没有想明白。点滴是什么?点滴是构筑希望的点点滴滴。所以,自检机制很重要。 +``` +def self_move(something) + if practice(something) == False + return None +self_move(MIT_record) +``` diff --git "a/source/_posts/2019-08-09-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\256\255\347\273\203\350\220\245-lecture9notes40.md" "b/source/_posts/2019-08-09-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\256\255\347\273\203\350\220\245-lecture9notes40.md" new file mode 100644 index 00000000..3247a1ed --- /dev/null +++ "b/source/_posts/2019-08-09-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\256\255\347\273\203\350\220\245-lecture9notes40.md" @@ -0,0 +1,45 @@ +--- +title: 1901030012-MIT-自学 lecture9 +date: 2019-08-09 15:53:09 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容: MIT第9课视频文稿p1- +- 学习用时: 20mins Notes no.: Day40 + +### 学习笔记 + +1. *和@王蕊一起看她的代码问题* + +没有看到原始书本上的代码,目前我还不能完全理解那段代码的具体问题,报错是显示syntax error,那么是某些部分的语法有问题,我理解是不是强行使用`int(str)`让某文本对象变成整数的问题?我们准备等晚一点她给我发一下那本书的代码页面照片。我再思考一下,然后一起分析。实在搞不定就群内求助。 + +2. *复习一下Pull Request* + +对于静态页面打卡的问题,根据@王蕊整理遇到的困难,再一起梳理一下: + +2.1 熟悉打卡模版格式Markdown文档要求的规范格式,通过自行练习输入的方式尽量完成。 + +2.2 使用Github Desktop与网页仓库进行push and pull,commit。 + +2.3 观察自己推到网页仓库的.md文档的格式显示的具体问题。 + +2.4 在本地仓库再次熟悉.md文档规范要求,调整后再update。再commit。 + +2.5 确认自己的文本符合规范后,准备new pull request。 + +2.6 @Maestro 然后留言等待审核merge,分享自己的最终文本显示页面链接到俺们营里。 + +3. *types vs. classes* + +**object-oriented programming and classes** + +So implementing the class meant defining your own object type. So you defined the object type when you defined the class. And then you decided what data attributes you wanted to define in your object. So what data makes up the object? What is the object, + +In addition to data attributes, we also saw these things called methods. And methods were ways to tell someone how to use your data type. So what are ways that someone can interact +with the data type, OK? So that's from the point of view of someone who wants to write their own object type. So you're implementing a class. + +4. 物理接近的好处就是,鲜活更具有说服力吧,keep alive。 diff --git "a/source/_posts/2019-08-10-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesD41.md" "b/source/_posts/2019-08-10-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesD41.md" new file mode 100644 index 00000000..8e709116 --- /dev/null +++ "b/source/_posts/2019-08-10-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesD41.md" @@ -0,0 +1,80 @@ +--- +title: 1901030012-MIT-自学 lecture9 +date: 2019-08-10 23:50:10 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容: MIT第9课视频文稿p2 +- 学习用时: 20mins Notes no.: Day41 + +### 学习笔记 + +1. [*Github Pulling changes from a remote repository*](https://help.github.com/en/articles/getting-changes-from-a-remote-repository#pulling-changes-from-a-remote-repository) + +`git pull` is a convenient shortcut for completing both `git fetch` and `git merge` in the same command: +``` +$ git pull *remotename* *branchname* +# Grabs online updates and merges them with your local work +``` + +Because `pull` performs a merge on the retrieved changes, you should ensure that your local work is committed before running the `pull` command. If you run into *a merge conflict* you cannot resolve, or if you decide to quit the merge, you can use `git merge -- abort` to take the branch back to where it was in before you pulled. + +2. [*Syncing a fork*](https://help.github.com/en/articles/syncing-a-fork) +- [x] 2.1 Open Terminal. +- [x] 2.2 Change the current working directory to your local project. +- [x] 2.3 Fetch the branches and their respective commits from the upstream repository. Commits to `master` will be stored in a local branch, `upstream/master`. +``` +$ git fetch upstream +> remote: Counting objects: 75, done. +> remote: Compressing objects: 100% (53/53), done. +> remote: Total 62 (delta 27), reused 44 (delta 9) +> Unpacking objects: 100% (62/62), done. +> From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY +> * [new branch] master -> upstream/master +``` + +- [x] 2.4 Check out your fork's local `master` branch. +``` +$ git checkout master +> Switched to branch 'master' +``` + +- [x] 2.5 Merge the changes from `upstream/master` into your local `master` branch. This brings your fork's `master` branch into sync with the upstream repository, without losing your local changes. + +``` +$ git merge upstream/master +> Updating a422352..5fdff0f +> Fast-forward +> README | 9 ------- +> README.md | 7 ++++++ +> 2 files changed, 7 insertions(+), 9 deletions(-) +> delete mode 100644 README +> create mode 100644 README.md + +``` + +If your local branch didn't have any unique commits, Git will instead perform a "fast-forward": +``` +$ git merge upstream/master +> Updating 34e91da..16c56ad +> Fast-forward +> README.md | 5 +++-- +> 1 file changed, 3 insertions(+), 2 deletions(-) + +``` + +3. 从Maestro给我们的参考资料入手,硬着头皮看了一遍,然后还是各种不知道该问什么问题。都不明白么?好像也不是。。。傻傻搞不明白这里面的具体操作,我就重新打字打一遍又看一次,well,好像没有那么陌生了,隐约觉得这个就是那天Maestro云淡风轻d秀肌肉使用的眼花缭乱的命令行技能???那我准备开始试着执行了哦。然后我就有第一个问题: +*3.1 打开的Terminal是Mac的么?还是可以在VSCode里面的terminal里呢?* + +果然哦,我在Mac的Terminal里输入的时候不知道要怎么输入 *remotename* 和 *branchname*,因为在`~`根目录下吧,所以报`fatal: not a git repository (or any of the parent directories): .git`。然后我在VSCode里面,显示的是我本地已经clone下来的selfteaching-learning-notes.github.io文件目录,然后`git pull`就居然就显示: +``` +cat at cattekimbp in ~/Documents/GitHub/selfteaching-learning-notes.github.io on source +$ git pull +Already up to date. +(base) +``` +尝试在Mac的Terminal里输入我猜的 *remotename* 和 *branchname*,我觉得我`.git`文件路径的问题么?是命名的问题么?我要去睡觉了,说不定我能梦到我在Google解。哈哈哈哈。加油,白天喝了咖啡再来玩。。。我觉得我似乎找到了一点儿`玩`的赶脚了。吾厘Maestro 万岁!!!yeah! diff --git "a/source/_posts/2019-08-11-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\256\255\347\273\203\350\220\245-lecture9notesday42.md" "b/source/_posts/2019-08-11-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\256\255\347\273\203\350\220\245-lecture9notesday42.md" new file mode 100644 index 00000000..18b5b0c1 --- /dev/null +++ "b/source/_posts/2019-08-11-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\256\255\347\273\203\350\220\245-lecture9notesday42.md" @@ -0,0 +1,43 @@ +--- +title: 1901030012-MIT-自学 lecture9 +date: 2019-08-11 23:20:00 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容: MIT第9课视频文稿p2-5 +- 学习用时: 20mins Notes no.: Day42 + +### 学习笔记 + +1. *self* +We defined the class in the sort of general way, OK? So we needed a way to be able to access *data attributes* of *any instance*. So we use this `self` variable, OK? And the self variable we used to refer to *any instance*-- to the data attributes of any instance in a general way **without** actually having a particular instance in mind, OK? + +2. *methods* +the bottom line of the class definition is that **your class defines all of the data**-- so data attributes-- and all of the methods that are going to **be common across all of the instances**. So any instance that you create of a particular object type, that instance is going to have this *exact same structure*, OK? The difference is that every instance's *values* are going to be different. + +So when you're creating *instances of classes*, you can create more than one instance of the same class. So we can create a Coordinate object here using this syntax right here. So you say the type, and then, whatever values it takes in. And you can create more than one Coordinate object. + +Each Coordinate object is going to have different data attributes. Sorry, *it's going to have different data attribute `values`*, OK? Every Coordinate object is going to have an x value and a y value. But the x and y values among different instances are going to vary, OK? **So that's the difference between defining a class and looking at a particular instance of a class.** + +So instances have the *structure of the class*. So for a coordinate, all instances have an x value and a y value. But the actual values are going to vary between the different instances. + +3. *Use OOB(Object-oriented Programming)* +so ultimately, why do we want to use object-oriented programming? So, so far, the examples that we've seen were numerical, right-- a coordinate, a fraction. But *using object oriented programming*, **you can create objects that mimic real life**. So if I wanted to create +objects of-- an object that defined a cat and an object that defined a rabbit, I could do that with object-oriented programming. I would just have to decide, as a programmer, what data and what methods I'd want to assign to these groups of objects. + +So I'm grouping sets of objects that are going to have the same attributes together. And attributes-- this is also a recap of last time-- come in **two** forms, right, *data attributes* and *procedural attributes*. So the data attributes are basically things that define what the object is. + +So how do you represent a cat as an object? And *it's up to you, as the programmer, to decide how you want to do that*. + +*Procedural attributes* were also known as *methods*. And the methods are essentially asking, what can your object do, OK? So how can someone who wants to use your object-- how can someone interact with it? + +4. *getters and setters* +All right, so now we have this class, Animal. We've done the first part here, which is to initialize the class, right? So we've told Python how to create an object of this type. + +There's a few other *methods* here that I've implemented. Next two we call *getters*, and the two after that we call *setters*, OK? And getters and setters are very *commonly used when implementing a class*. So getters essentially return the values of any of the data attributes, OK? So if you look carefully, `get_age()` is just returning `self.age` , and `get_name()` just returns `self.name` . So they're very simple methods. Similarly, `set_age()` and `set_name()`-- we're going to see what this funny equal sign is doing here in the next couple of slides. But setters do a very similar thing where they're going to set the data attributes to whatever is passed in, OK? + +5. `#学习Python有力量`,我已经可以和Alucard沟通某些我原来完全不知道要怎么沟通的话题,因为原来在他提到的那些概念、理论时我完全不能听到大脑里,因为我完全不熟悉,,,现在,我感觉我不会因为害怕而宕机不听了,我会尝试提问,还是in a smarty way。hiahiahia。 diff --git "a/source/_posts/2019-08-23-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesday43.md" "b/source/_posts/2019-08-23-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesday43.md" new file mode 100644 index 00000000..92d47467 --- /dev/null +++ "b/source/_posts/2019-08-23-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesday43.md" @@ -0,0 +1,61 @@ +--- +title: 1901030012-MIT-自学 lecture9 +date: 2019-08-23 04:30:00 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容: MIT第9课视频文稿p6 +- 学习用时: 128mins Notes no.: Day43 + +### 学习笔记 + +1. **Information hiding** + +> So the whole reason why we’re using **classes** in object-oriented programming is so that you can abstract certain data from the user. One of the things you should be abstracting is these data attributes. So users shouldn’t really need to know how a class is implemented. +> They should just know \_how to use the class.\_ + +> Eg: Let’s say whoever wrote the Animal class wants to change the implementation. And they’ve decided they don’t want to call the data attribute “age” anymore, they want to call it “years,” OK? So when they initialize an animal they say `self.years = age`. So an animal still gets initialized by its age. And the age gets passed into a data attribute named “years,”. + +> Since I’m implementing this class, I want to have a getter, which is going to return `self.years`. So I’m not returning `self.age` anymore, because age is no longer the data attribute I’m using. So with this new implementation, if someone was using this implementation and was accessing age directly as— was accessing the data attribute age directly— with this new implementation, they’d actually get an *error*, right? **Because this animal that they created using my old implementation no longer has an attribute named “age.” And so Python’s going to spit out an error saying no attribute found or something like that.** + +> If they were using the getter `a.get_age()`— the person who implemented the class reimplemented `get_age() `to work correctly, right, with their new data attribute, years, as opposed to age— so if I was using the getter `get_age()`, I wouldn’t have run into the bug, OK? So things to remember— _write getters and setters for your classes._ And _later on in your code, use getters and setters to prevent bugs and to promote easy to maintain code._ + +> *so information hiding is great.* But having said that, Python’s actually **not very great at** information hiding, OK? Python allows you to do certain things that you should **never** be doing: +> _1._ The first is to access data attributes from outside of the class, OK? So if I were to say a.age, Python allows me to do that without using a getter and setter. +> _2._ Python also allows you to write to data attributes from outside the class. [Eg](: So if I implemented the class Animal assuming that age was a number, an integer, and all of my methods work as long as age is an integer, but someone decided to be smart and, outside of the class, set age to be infinite as a string, that might cause the code to crash, OK? Python allows you to do that. But now you’re breaking the fact that age has to be an integer, right? So now the methods should probably be checking the fact that age is an integer all the time.) +> _3._ The other thing that you're allowed to do is to create data attributes outside of the class definition. [Eg](So if I wanted to create a new data attribute called “size” for this particular instance, Python also allows me to do that. And I can set it to whatever I want, OK? So Python allows you to do all these things, but it’s actually not good style to do any of them. So just don’t do it. All right.) + + +2. My boogieman is living in my illusion. Too much read between the lines. + +3. 我就是想得offlined多一些。我如果不想做,想啥都不切题。有病要治,尝试找解药: + +\_3.1_ `Marcus.sleightofhand` + +> **“上手”,才能解决焦虑。**“上手”,没有重点,但是有“通”点。……永远记得,我们真正的目标是,“上”手。 + +> ……如何给自己制造反馈。要制造反馈,你必须先有成果,制造反馈的目的就是要基于已有的成果来发现问题。所以要制造反馈,我们可能要写一点东西,录制一点音频,甚至录像,这些是给自己制造反馈的最佳手段。总结来说就是要及时输出。 + +> 你学了一些东西之后,一定要想办法讲出来或应用出来,这正是给自己制造反馈。所以你一定要积极地给别人讲东西,…… + +> 缺少反馈的一个最常见的情况是,我们平时会看一些书,看完了也就过去了,时间长了也就忘记了。就是因为没有反馈,我们并没有笑话书中的重要内容。 +> **—— Marcus XU “SLEIGHT _OF_ HAND”** + +\_3.2_ `My Angel.letustalkaboutit` + +@糖糖今天在AMA里也回答了我的问题,以任务为导向开干,而且不能闭门造车,要持续反馈和反复沟通。 +所以,实际上最好的antivirus methods就是该干嘛干嘛,该作作业啊,,,“躲”着是个什么事儿,打开了作业指引读不进去的主要原因就是没想做作业。。。一条一条的读,记住自己读这个指引的任务是什么,拆解到最小单位的尝试输出,if offlined please try shifting back,practice makes progress。 + +\_3.3_ `Max.piggiefight` + +其实最大的鼓励还是来源于Max猪,他和爸比在玩的有一个游戏就是统计类的,然后他昨天的观察作业就是花的结构。和我数据营的作业一毛一样啊,,,他也不知道完整的统计啊,他也一开始并不全面知道花的那些结构的名词和作用啊,人家就是不怕地、兴致勃勃地完成自己的任务啊,他特别不理解的看着我苦闷的脸,然而,他还是patpat我说:麻麻你别怕哈,你来用电脑写你的作业,不懂的,我来教你。 + +4. **Eyes on “ME”**. + +哎,四岁八个月的“我”,比同龄Max却还有很多心理建设需要做,好吧,还好我有Max的鼓励和支持,有这个自学营的小伙伴们,也说明我进步了,至少我不像以往那样封闭,而是在努力地追望着营友们的背影,现在爬行追赶。 + +我们每个人的学习方法是不同的,要摸索自己适合的方法,摸索靠``“上手”``呀,谢谢自学营里每一位campmates们的鼓励、帮助与支持,有你们的世界真好,**加油Cat!** 感谢教练们,,,让我再gu(四声)qiu(轻声)一会儿。。。。。。黑线脸喵。。。 diff --git "a/source/_posts/2019-08-30-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesday44.md" "b/source/_posts/2019-08-30-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesday44.md" new file mode 100644 index 00000000..d2ff8401 --- /dev/null +++ "b/source/_posts/2019-08-30-1901030012-\350\207\252\345\255\246\350\256\255\347\273\203\350\220\245-MIT-Python\350\220\245-lecture9notesday44.md" @@ -0,0 +1,61 @@ +--- +title: 1901030012-自学训练营-MIT-自学 lecture9 +date: 2019-08-30 23:59:09 +tags: ['MIT', 'Python', '学习打卡'] +categories: 'MIT60001' +--- + +### 学员信息 + +- 学号: 1901030012 +- 学习内容:MIT视频文稿lecture9p7-8 +- 学习用时:145mins Notes no.: Day44 + + + +### 学习笔记 + +1. **default arguments** + + > because newname actually has a default argument, OK? So that tells Python, if no parameter is passed in for this particular formal parameter, then use whatever is up here by default. So if I haven't passed in the parameter a.get_na-- a.set_name(), sorry-- a.sett_name() is going to be setting the name to the empty string, because that's what the default parameter is. So in the next line, when I print a.get_name(), this is just going to print the empty string, + + > + > + > Whatever you pass in overrides the default argument, and everything is good. + + > If you don't provide a default argument for newname and you do this case here, then that's going to give you an error. + + 如果有默认值的,不赋值就使用默认值,如果没有设置默认值,python也会friendly的使用报错提示需要至少默认值赋值。 + + + +2. **hierarchies** + + >So the great thing about object- oriented programming is that it allows us to add layers of abstraction to our code, all right? So we don't need to know how very, very low-level things are implemented in order to use them. And we can build up our code to be more and more complex as we use up these different abstractions. + + object -- Parent class -- child class + + 十分形象的表达,我终于看到营友们之前提到的继承了。。。 + + + +3. what will happen? + + > So the idea here is, when you have hierarchies, you have a parent class, you have a child class, you could have a child class to that child class, and so on and so on. So you can have multiple levels of inheritance. + + > What happens when you create an object that is of type something that's been-- of a type that's the child class of a child class of a child class, right? What happens when you call a method on that object? Well, Python's are going to say, does a method with that name exist in my current class definition? And if so, use that. + > + > But if not, then, look to my parents. Do my parents know how to do that, right? Do my parents have a method for whatever I want to do? If so, use that. If not, look to their parents, and so on and so on. So you're sort of **tracing back up** your ancestry to *figure out* **if you can do this method or not**. + + wow, niubility... + + + +4. avaibility cascades shuffled me...我太关注那部分超小概率事件,不过,能观察到自己的注意力受到的外部压力影响,也是很开心的一点收获,还好有俺们营这个habitat,我再shifting away都能游回来。感谢这里的所有人。 + + + +5. 硬着头皮和教练沟通,加上自己数据营的作业的进展,让我开始理解寻找适合我的方法时候已有方案可以再改进的地方,我还是被自己的一些原有不清晰的概念而限制了。完成任务是目标,eyes on the very task!出発する。 + + +