Skip to content

2019-08-31-1901030012-自学训练营-MIT-Python营-lecture9notesday44 #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: source
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8d80b9e
Create 2019-08-02-1901030012-自学数据营-自我介绍.md
catynchyna Aug 2, 2019
dfa6811
Update 2019-08-02-1901030012-自学数据营-自我介绍.md
catynchyna Aug 2, 2019
b919677
Create 2019-07-30-1901030012-自学训练营-MIT-Python课-lecture8notes37.md
catynchyna Aug 2, 2019
8c82f73
Update 2019-08-02-1901030012-自学数据营-自我介绍.md
catynchyna Aug 2, 2019
2a1c0a3
Merge branch 'source' into source
yingca1 Aug 2, 2019
0d7c0cc
Create 2019-08-06-1901030012-自学训练营-MIT-Python课-lecture8notes38.md
catynchyna Aug 6, 2019
c101c1e
Update 2019-08-06-1901030012-自学训练营-MIT-Python课-lecture8notes38.md
catynchyna Aug 6, 2019
3493f1b
Update 2019-08-06-1901030012-自学训练营-MIT-Python课-lecture8notes38.md
catynchyna Aug 6, 2019
67beebf
Update 2019-08-06-1901030012-自学训练营-MIT-Python课-lecture8notes38.md
catynchyna Aug 6, 2019
d21bb30
MIT营+数据营思考记录打卡
catynchyna Aug 8, 2019
98390d3
Update 2019-08-07-1901030012-自学数据营-作业1思考记录001.md
catynchyna Aug 8, 2019
d3c975f
Update 2019-08-07-1901030012-自学数据营-作业1思考记录001.md
yingca1 Aug 8, 2019
f481635
Create 2019-08-09-1901030012-自学训练营-MIT-Python训练营-lecture9notes40.md
catynchyna Aug 9, 2019
1044d05
Create 2019-08-10-1901030012-自学训练营-MIT-Python营-lecture9notesD41.md
catynchyna Aug 10, 2019
074d143
Create 2019-08-11-1901030012-自学训练营-MIT-Python训练营-lecture9notesday42.md
catynchyna Aug 11, 2019
eafc77c
Create 2019-08-23-1901030012-自学训练营-MIT-Python营-lecture9notesday43.md
catynchyna Aug 22, 2019
6ec81f4
Update 2019-08-23-1901030012-自学训练营-MIT-Python营-lecture9notesday43.md
catynchyna Aug 22, 2019
a77e825
Update 2019-08-23-1901030012-自学训练营-MIT-Python营-lecture9notesday43.md
catynchyna Aug 22, 2019
6bcadb0
Create 2019-08-30-1901030012-自学训练营-MIT-Python营-lecture9notesday44.md
catynchyna Aug 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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。
感谢营友们的美好,这个世界有你们真好!!!
加油!
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ categories: '自我介绍'

### 自我介绍


1. 自我介绍:

本人叫王露萩,朋友都叫我Cat。中国和美国加州执业律师。实际心理年龄只有4岁8个月左右,对世界开启了好奇心。我可以使用中文、英文。在学习使用Python和日文。

2. 为什么想学习数据分析:
Expand All @@ -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 看见数字和图表内心深处阴影面积暂时还是会产生巨大压力影响自己的学习动作变形。
Original file line number Diff line number Diff line change
@@ -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. 我来实验一下啊,我怎么不能换行(据说是要空两个空格啊)呢?还有就是最最最简单的图表怎么就是搞不定呢?(不是搞不定,是眼睛无比的粗心大意,,,使劲盯着看,,,我舅说的没错,规范啊规范很重要,那就盯着盯着的不就找出来不同了)。然而,这个列表的点点是怎么输入进去的呢?!让我再纠结一会儿吧。
Original file line number Diff line number Diff line change
@@ -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` **玩** 起吧。
Original file line number Diff line number Diff line change
@@ -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)
<class __main__.Coordinae>
print(type(Coordinate))
<type 'type'>

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)
```
Original file line number Diff line number Diff line change
@@ -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。
Loading