1901050136-自学训练营自学7群-自学是门手艺
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 01 preface study notes>
- 学习用时:<60mins>
学习笔记
<收获总结>
读书 自学是门手艺 日期:7月25日 Day15
学习内容:01 preface study notes
Self-studying is just one craft, and programming is just one craft, too. They are not those profound talent that is unattainable. Sometimes, one may emphasize the difficulty of some skills and use this as the excuse to refuse to do learn them. Indeed, in this world talent is needed in some cases, but not so many occasions where it is indispensable. So at the very beginning, I should know self-studying and programming are just craft, which means they can be mastered.
Knowing that is far from enough. Most of those who know this truth can not achieve success eventually since they can not put their ideas into practice. And the case that one knows this truth but cannot practice that will make oneself more anxious. To achieve the goal and gain the skills, all we need to is teaching ourself and practicing all the time. The knowledge is easier and practice is harder in this case. Therefore, when studying these skills, we need to practice them, again and again, to make ourselves to be proficient.
所以,十岁不到的时候,绝大多数小朋友就 “看穿” 了父母,后来再 “看穿” 了老师…… 发现他们整天说的都是他们自己做不到的事情…… 于是误以为自己 “看穿” 了整个世界。
那时候小朋友们还没学、或者没学好概率这个重要知识,于是,他们并不知道那只不过是 99% 的情况,而且更不知道 “因素的重要性与它所占的比例常常全无正相关”,所以当然不知道那自己尚未见到的
1%才可能是最重要的……
于是,99% 的小朋友们一不小心就把自己 “搭了进去”:
These sentences impressed me. Until I read those sentences I have still held those ideas in my mind. Since during my growing up, I encountered some many people who told the truth which they did not follow and is just used to educate others. To be honest, to date someone around me still does the same thing. This case makes me skeptical and tired of what he told me. From these sentences, I think more about that. The truth is not wrong and the people who just say them and do not practice them is totally wrong.
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 02 proof-of-work>
- 学习用时:<30mins>
学习笔记
读书 自学是门手艺 学时:7月26日 Day16
学习内容:02 proof-of-work
This chapter focus on how to use the GitHub as a tool for our programming studying. Github is a version management tool, and the most commonly used code management tool nowadays. It is a little tricky to be understood. I am learning more about this recently. Ever before, I was just searching for some good examples in the github.com, which is a big treasury. I have found a lot of useful study resources here. Actually, I didn't learn how to use it.
When studying git, I think I need to figure out the design logic of the git. Since for a specific tool, it has its own logic when being designed. And this thought is also suitable for learning other knowledge. In conventional Chinese education classes, instructors are always telling us the knowledge directly and straightforward, and do not tell us more about what the purpose of the knowledge when first being proposed, which makes the teaching boring and hard to understand. Since all the knowledge is proposed to solve some specific questions, if we can be aware of the questions in advance, it will help us know the knowledge deeply and easily.
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 02 proof-of-work-2>
- 学习用时:<30mins>
读书 自学是门手艺 学时:7月27日 30 mins Day17
学习内容:02 proof-of-work-2
Today I watched a series teaching videos of Git. I think it is very easy to understand and very clear. For your information, the link is: https://morvanzhou.github.io/tutorials/others/git/2-1-repository/
record the user's information/
git config --global user.name "Shaun Cui"
git config --global user.email "[email protected]"
git config user.name
git config user.email
hidden folder
Initialized empty Git repository in /.../.git/
git init
show all the folders
ls -a
open the specific folder
open .git
create the file of 1.py
touch 1.py
check if the file in the folder
git status
add the file 1.py to staged file
git add 1.py
add all the file to staged file
git add .
commit a modified file
git commit -m "create 1.py"
the different status of the file

学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 02 proof-of-work-3>
- 学习用时:<30mins>
读书 自学是门手艺 学时:7月28日 30 mins Day18
学习内容:02 proof-of-work-3
how to modify a file and save the edition, for example, the 1.py file
first open the 1.py and work on it
then on the bash board, input git add 1.py(change to staged status)
Use git status to check the status of file to show that the '1.py modified'
Use git commit -m "change 2 " to commit the change edition the git
Use git log to check all the modifications
use the status of the files in a concise formation
git status -s
check the difference of the unstaged file
git diff
check the difference of the staged file with previous committed status( to check the staged one)
git diff -cached
check the file with two different changes, one is unstaged while another is staged
git diff HEAD
check all the change information in one line
git log --online
commit one change to last change, to amend them together
git commit --amend --no-edit for example, after committing 1.py, we wanna commit 2.py together with 1.py when can use this input
go back to past
from staged to modified
first , git add 1.py git reset 1.py then
modified for git is the staged
from commited to staged
git commit -m "change 5" # commit git reset --hard HEAD
git reset --hard HEAD^ # go back to last step ^^ last last step
git reset --hard HEAD~n # go back to nth previous step
git reset --hard head ID
go back to future
git reflog # see all the head's transmitting
git reset --hard head ID # go back to the specific ID of the head
git reset --hard HEAD@{4} # pointer
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 02 proof-of-work-4>
- 学习用时:<30mins>
读书 自学是门手艺 学时:7月29日 30 mins Day19
学习内容:02 proof-of-work -4
Checkout for a specific folder
git checkout -- 1.py
the reset method is aimed at the repository. while the checkout is to operate in the file and do not have the operation in the repository.
the branch is to provide different users different version
git log --online --graph # which is used to show all branches
git branch dev # build a new branch
git branch # check all branches
git checkout dev # switch the head to the branch of dev
git branch -d dev # delete the indicated branch but we cannot delete branch itself when the head is in that branch
git checkout -b dev # another way to build a branch
git commit -am "change 3 in dev" # add and commit together
merge the branch together, for example, merge the dev to master
first, go back to the master branch then git merge --no-ff -m "keep merge info" dev # no fast forward make keep the information
merge branch errors
which means if you wanna merge to modified files together that is the errors. Then we need to handle this question by hand. delete these error info in the file. Then add and commit the file to the repository.
rebase branch errors
do the same thing with the merge. and then in the branch of master git rebase dev
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 Part 1.A. , Part 1.B.>
- 学习用时:<30mins>
读书 自学是门手艺 学时:7月30日 30 mins Day20
学习内容:Part1.A. , Part1.B.
some thoughts.
Giving up is an easy thing and always happening around me. Of course, there are many reasons responsible for that and also some excuses will be found by ourself to persuade ourself. After time flying, we may forget about that. Persistence is a good value for all of us.
Then, programming is a basic tool for us in the current era. For me, I wanna do something related to big data, the python is the best programming languages to learn now. With the advancement of the technique of the sensor, more data will be collected in various industries, data-driven methods will play their roles here. That is the long-term goal for me learning python.
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 Part1.C. and D. >
- 学习用时:<60mins>
学习笔记
读书 自学是门手艺 学时:7月31日 60mins Day21
学习内容:Part1.C. and D.
some thoughts.
Book's importance.
To be honest, in the past, my opinion about books is also that books are not useful for everything although I love reading books. I ever concluded the reason why I read books and I thought that killing time is one solid reason.
When I reading some sentences in the part.1.c, I thought this question deeply and got some new ideas.
First, books may not be able to teach us everything but what else can teach us everything? Comparatively, the book may be the best teacher for us. Second, what is a book? The stuff all that can teach you is able to be reckoned as books. In the text, the Internet was described as a book, and also other things can also be thought so, such as a person, the society and so on. Just as one sentence in the Red Chamber Dream said,
A grasp of mundane affairs is genuine knowledge, and understanding of worldly wisdom is true learning(世事洞明皆学问,人情练达即文章). The books we read are in the format of words that take the useful knowledge we need. Third, the selection of books is also vital for our feeling of reading books. Sometimes we will think that reading books is not a good way for self-studying since the books we select is bad and low-quality.
When we study something new, how to get out of being stressed and panic?
当我们开始学习一项新技能的时候,我们的大脑会不由自主地紧张。可这只不过是多年之间在学校里不断受挫的积累效应 —— 学校里别的地方不一定行,可有个地方特别行:给学生制造全方位、无死角、层层递进的挫败感。
That is true for me. When I study something new and find something hard to understand, this motion comes to me immediately. I think this thinking pattern is built in mind, and I need to learn how to get rid of this. First, I need to know that do not fear those studying we are learning. Second, practice to calm down and adjust my mind at this moment. <遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 Part1.E.1>
- 学习用时:<40mins>
学习笔记
学习内容: Part1.E.1
读书 自学是门手艺 学时:8月1日 40 mins Day22
recap
This part is to introduce some basic concepts for programming and python language.
The story of George Boole is used as the entrance of the programming language. He is a good example for self-studying and his book is needed to read in the future.
The one invention of Boole is the boolean operands and this can be applied to control the flow of programs. It tells the program when to go to a specific case and when to stop. In python, if-else is used to do this.
The program is aimed to implement a thing. For a specific program, its efficiency can be improved further. This is the research of algorithm optimization. This is a high-level thing since it needs wisdom and thoughts and is not a just thing of the tool.
The function is used to encapsulate a certain program and make it can be applied in other places, i.e. calling or invoking functions.
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 Part1.E.2>
- 学习用时:<40mins>
学习笔记
读书 自学是门手艺 学时:8月2日 Day23
学习内容: Part1.E.2
<收获总结>
recap
This part illustrates the details of the evaluation.
The basic types of data and complicated types of data are introduced. They are all the types of values, and in detail what we do is in the values.
For the values, they can be used to construct different types of data, except basics types, list and others can also be used. Then different operations are used to process these values. Except for basic operators, Python itself has its own built-in functions and other functions from other libraries.
The aim of our learning: first learn the types of data and then learn how to call functions or how to design functions, to process those types of data.
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 part1.E.3 >
- 学习用时:<40 mins>
学习笔记
读书 自学是门手艺 学时:8月3日 Day24
学习内容: Part1.E.3
学习笔记
<收获总结>
recap
for arguments 1:
if arguments 2:
break
else:
sentence 1
for-else is special stuff for a programming language. It means if break does not happen then the sentence 1 under else will work. This idea is cool and sees an example.
for i in range(0,10):
if i % 2 ==10:
break
else:
print('1')
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 part1.E.4 >
- 学习用时:<40 mins>
学习笔记
读书 自学是门手艺 学时:8月4日 40 mins Day25
学习内容:Part.1.E.4
<收获总结>
recap
The understanding of the positional arguments and keyword arguments. In the parenthesis of the function, the arguments can be divided into two categories.
One is the keyword argument which has =, and the other is the positional argument. For the positional argument, there can be many positional arguments, and the * is bonded to the positional argument, and this kind of positional argument should be put at the last position among all positional arguments.
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺part1.E.5-1 day26>
- 学习用时:<40mins>
学习笔记
读书 自学是门手艺 学时:8月5日 40 mins Day26
学习内容:Part.1.E.5-1
学习笔记
<收获总结> The content about the string is a little long. Today I learned the first part of the part.
A String is a basic object in Python, and it's a sequential and immutable object.
A single char can be transferred to a number by the built-in functions of ord() and chr().There are four ways to define a string, i.e. 's','''s''',"s", and """s""". We can use str(),the built-in function to transfer any number to string, while we can also use int() and float() to transfer a string to a number, which only works when the string is transmitted to the type of number inside the quotation marks,that is, "3.14" can only use float("3.14"), and int("3"), and int("3.14") wrong.
Escape character is to indicate some specific characters by combining with '\'. The operands can also be used in strings, such as s*3 means iterating the s three times. + or space can be used to combine two strings. The slice of a string can be indexed by using the element's position number. The built-in function of len() is to return the length of a string and print() can print the string on the dashboard directly.
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺 Part1.E.5-2>
- 学习用时:<60 mins>
学习笔记
读书 自学是门手艺 学时:8月6日 60mins Day27
学习内容:Part.1.E.5-2
<收获总结>
-
1 When utilizing
.strip("ss")to remove the slices from strings, the chars in the "ss" will be got rid of until there is no char at the beginning and the end in the object of string. -
2 For separating strings,
.splitlines()could be able to convert a string to a list..split('s')could be used to split strings up by the input parameter 's'. In the function of.split(sep = 's', maxsplit = N), the number 'N' stands for split how many times for the string, and the default no. is -1, which means split the object of string thoroughly. -
3 For concatenating strings, the
.join('s')stands for every slice in the object of the string before.will be stick with 's', put it in another word, the 's' would input 's' between every two slices. For e.g,'python'.join('*')'s result isp*y*t*h*o*n. -
4 The difference of isdigit、isdecimal、isnumeric
True:unnicode数字、byte数字(单字节)、全角数字(双字节) False:汉字数字、罗马数字 error:无```
True:unnicode数字、全角数字(双字节) False:汉字数字、罗马数字 error:byte数字(单字节)```
True:unnicode数字、汉字数字、全角数字(双字节) False:罗马数字 error:byte数字(单字节)```
版权声明:本文为CSDN博主「艾力亚斯」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_40457797/article/details/85622055
- 1 one exception I faced is that
.isascii()doesn't work in my jupyter notebook. e.g.
a = 'a'
'aa'.isascii()```
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学是门手艺part1.E.6-1>
- 学习用时:<30mins >
学习笔记
读书 自学是门手艺 学时:8月7日 30mins Day28
学习内容:Part.1.E.6-1
<收获总结>
This part is focused on containers, and the first one is List class.
- 1 List comprehension: a very useful method to generate sequence data.
a_list = [random.randrange(1, 100) for i in range(n)] # generate 10 a list with 10 random number in range of ....
print(f'a_list comprehends {len(a_list)} random numbers: {a_list}')
The following is the explanation for that.
eg_list = [ random.randrange(1,30) for i in range(1,10)]
oo = [x**2 for x in eg_list if x % 3 == 0]
is equal to
eg_list = []
for i in range(1,10):
eg_list.append(random.randrange(1,30))
oo = []
for x in eg_list:
if x % 3== 0:
oo.append(x**2)
- 2 A special feature of List. Since List is mutable, which is different from the immutable containers such as String, a List object's class methods is different from the built-in functions. That is the class methods of List will do operation on the object itself and return a processed object. For example,
object.sort()would return a None, which is similar to theprint('s')which just print 's' to dashboard and return None.
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群 Day29 20190808>
- 学习用时:<自学是门手艺part1.E.6-2>
学习笔记
读书 自学是门手艺 学时:8月8日 60mins Day29
学习内容:Part.1.E.6-2
This part is focused on containers, and except List, there are also other objects including Tuple, Set, dictionary.
- Tuple
- The tuple is ordered and immutable, while List is ordered and mutable.
- initialization of a Tuple
a = 2,equals toa = (2,)- The immutation means the current part of the Tuple cannot be modified.
Tuple1 + Tuple2to extend theTuple1is allowed.
- Set
- Set is disordered and has two sub-classed. One is the common Set, which is mutable, and the other is frozen set, which is immutable.
- set comprehension is similar to List.
- Set's operands can handle two or more sets. And Set's logic operands can judge the relationship between or among two or more sets.
- Set can be updated and frozen Set is similar to Tuple being compared to List.
- Dictionary
dict1.update(dict2)means add dict2 into dict1.del dict[key]means delete the slice with the indicated value inside the bracket parenthses.- Dict‘s operands can return
dict_key(keys' List),dict_value(values' List)anddict_items([(key_1,value_1),(key_2,value_2),...,(key_len,value_len)]).- Dict's built-in functions all operate Dict's Key part rather than its Value part.
- Iteration for these containers
- getting elements and their own indices meanwhile using
for elem, index in enumerate(Ob), in whichObcan be List, tuple, and set.reversed()andsorted()return an object rather than an None, which is different from thesort()andreverse(). (This is indicated in The MIT Python Course.)zip()is used to handle two containers' iteration.- Dict's iteration:
for key, value in Dict:.
<收获总结>
<遇到的难点与问题(是否解决)>
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺part1.E.7>
学习笔记
读书 自学是门手艺 学时:8月9日 40mins Day30
学习内容:Part.1.E.7
This part focuses on introducing how to process files in Python. The basic contents are included as follow.
- 1 Creation of files
open(filename, mode), in which the most commonly used are 'w'(standing for writing mode) and 'r'(stands for reading mode).
- 2 deletion of files
OS.remove(), and it is best that the existing of a specific is checked in advance.
Files need to be closed using file.close() before being removed.
- 3 Reading and writing of files
file.read() return the text(with a type of str ) of the file.
file.readline() returns a line of the text once it is called.
file.readline().strip() is used to get rid of the ' ' and '\n' like special chars.
file.readlines() (look out the s in the method's name) return a List processed from the text of the file.
file.writelines() writes a list object to the file.
- 4 with to enclose codes
with open(filename, mode) as f: is to used to process the specific file and file.close() can be omitted here.
- some notes from others:
a = 1
'{:10.2f}'.format(a)
a = 'a'
b = '{:11}'.format(a)
print(b)
len(b)
In {:10.2f}.format(a), 10 means the whole length of the string and 2 indicates the precision (the number of the digits after the decimal point).
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺part1.E.8>
读书 自学是门手艺 学时:8月10日 40 mins Day31
学习内容:Part.1.E.8 Deal with forward reference
This part gives some tips for handling forward reference problems.
-
1 what is forward reference(FR)? For understanding, since the structure of knowledge is not linear, which means the parts of knowledge is reciprocal causation. We would like to follow the pattern
A -> Bwhen studying, which means before processing B, A is needed in advance. However, this pattern is the logic of school education. In real life, it is a different case. The pattern of the parts of knowledge seems to beA <-> B, which indicates that we need to study the other when we study one part. It makes our mind messed up sometimes. -
2 FR is existing everywhere. That is different from the knowledge structure of school education. That is one reason we feel frustrated in real life.
-
3 Coping strategies
- First, go over the whole book(or other things) roughly(, even if we cannot understand a lot of details), and then repeat to improve.
- Read word by word when reading books. It means we should read books very seriously. That is different from reading novels, where I more pay attention to the emotion.
- Repeating, organizing notes, summarizing,and concluding as soon as possible. These would help remember and understand knowledge deeply.
- Use first and then try to understand theories.
- Follow senior worker's advice. We always feel bored with some advice, since the persons who told me do not follow it. But the advice itself is good and helpful.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺part1.G.>
读书 自学是门手艺 学时:8月11日 30 mins Day32
学习内容:Part.1.G. The Python Tutorial local
I have gone over the first seven parts of this book which of them gave the basic knowledge of the Python. These are not enough and can just be the entrance of programming. When we learning, the most useful reference is the Offical Tutorial released by Python designers.
For me to be honest, I did not like querying the Official tutorials in the past. Since I found I was not patient when reading the official tutorial, which is long and sometimes hard to quickly understand. I prefer searching on google. Now, I think it is a good habit to use the official tutorial. I would more like to use this tutorial in the future.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.A. >
读书 自学是门手艺 学时:8月12日 30 mins Day33
学习内容:Part.2.A. Clumsy and patience
some thoughts after reading the part
Some words and sentences impressed me when I reading them since I had similar experiences and feelings. The following are some thoughts.
- Repeating
When we studying something, it is impossible to acquire that immediately. Thus, the only way we can solve this problem is by repeating. Going over the content we have studied, again and again, until to achieve the expected goal.
I have one experience of this. That is in the last year of my undergraduate when I was about to attend the Graduate Entrance Examination. Since my undergraduate university is a low-ranking, I intended to go to a university at a higher level. For the Entrance Examination, the most important subject is advanced mathematics, since it is hard and can help increase the grade gap with other candidates.
I spent almost half a day every day in the 10 months during the exam preparation period. I read textbooks, watched teaching videos and practiced problems. I took three full-page notebooks, and I went over these notebooks frequently. This progress helped me get a good grade in the maths examination and be admitted to university I planned to attend.
The time when I was preparing my graduate entrance examination is the most hardworking period during the whole undergraduate period. To date, I still remember those days, since I was concentrated on studying at that moment. During the preparation, I had found the repetition of going over notes was the best way to learning something because it would help you reconstruct the structure of the knowledge and impressed the knowledge in my mind.
This is an example of preparation for exams, and I always think the preparation for exams or the studying for examinations rely on deliberate practice rather than genius.
Repeating is the only way to get familiar with the basic knowledge and deepen the impression of the knowledge in my mind, and connect it to the previously learned knowledge. In a nutshell, that is the only way.
However, that is not easy, since we are short of patience.
- Patience
Patience is one rare resource, at least for me. When I find something I have studied, but I cannot remember that clearly or it was messed up in my mind, I would feel anxious and impatient. It is also hard to focus on the work that cannot give you a positive response for a long while.
- Psychological budget
Studying is not an easy thing, and no pains and no gains. How much "pains" we would like to pay depends to some extent how much we could gain consequently.
we always fancy getting a good result by paying a little thing. We would like to gain success easily. However, it is impossible. Thus, we need to have a big mental budget for those we would like to learn since if you are unwilling to paying a lot of efforts, we cannot make it. All the little paying is useless and just a waste of time. Therefore, either try the best or do nothing when studying.
- Failure examples
When I was younger during the period of undergraduate, I also have a lot of hobbies, including guitar, harmonica, pencil painting, writing novels, and so on. But I did not well in all of these things since I did not deliberately practice them.
I studied playing guitar during undergraduate, but I am not patient when deliberately practicing, so until now I am just able to play some easy songs. Therefore, the self-studying for Python is just the first step, I could do more things in the future.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.B. >
读书 自学是门手艺 学时:8月13日 30 mins Day34
学习内容:Part.2.B. Deliberate Practicing
Deliberate practicing needed attention and time. It has two steps: 1) Think about which parts require to practice. 2) Practice these parts.
Just deliberate practicing is studying. Sometimes, we spend time on these things that we have totally familiar with. It is useless. Just like when practicing guitar, if I just practice the songs I have learned, it will not improve the skill of playing the guitar.
One tip to promote deliberate practicing.
-
take notes when finding some parts requiring deliberate practicing.
-
Review the notes and sort the priority the notes.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.C. and D.1. >
读书 自学是门手艺 学时:8月14日 Day35 60 mins
学习内容:Part.2.C. and D.1
A function is a complete program including input, processing, and output.
Some Notes:
1. Name a function
Letters, numbers, and _ can be used. Letters cannot be as initials. Keywords defined by Python in advance cannot be used.
2. Functions receiving no arguments
3. Functions with no return The default return is None, which can be used as condition statement.
4. Functions receive one or more arguments from external
5. Scope of the variable
The variables(not mutable container)outside and inside function are different.
Variables outside functions are global, while those inside functions are local. Outside variables just give their value( not all of themselves) to the functions. Put it another way, functions just use the value of the input global variables and do not change them at all.
However, when the input variable is a mutable container(such as List), this is a different case. The operation inside functions would change the input mutable container. In this case, it is better to use a copy of the input variable in the function.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.D.2 >
读书 自学是门手艺 学时:8月15日 Day36 60 mins
学习内容:Part.2.D.2
For the arguments, there are two categories of them. One is the positional argument, and the other is the keyword argument. Keyword arguments are those which have default values, i.e. like the format of para = 1. Those having no default are positional arguments.
Common keyword arguments and positional argument can just receive one argument(including different types). If we would like to give a series of arguments to functions, arbitrary positional arguments and arbitrary keyword arguments are needed.
1. Arbitrary positional arguments
This kind of arguments has a sign *, and the sign * is required when defining and also calling functions.
Functions will regard arbitrary postional arguments as containers (List,Tuple,Dict,set).
The for...in..: statement can be used here.
Attention: One function can just have one (*arguments). If there are also other positional arguments, (*arguments) is must be ordered at the end of all positional arguments.
2. Arbitrary keyword arguments
This kind of arguments has a sign **, and the sign of ** is also required when defining and also calling functions.
Functions will regard Arbitrary keyword arguments as dictionaries.
The for...in..: statement can be used here.
3. The sequence of arguments in functions
Order of Arguments
- Positional
- Arbitrary Positional
- Keyword
- Arbitrary Keyword
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.D.3 >
读书 自学是门手艺 学时:8月16日 Day37 60 mins
学习内容:Part.2.D.3 Lambda
- Alias is used to give a function with an alias, a new nickname. The alias and the original name of the specific function represent the same in function in memory.
The syntax:
alias_name = function_name(no parenthses and arguments)
- Using Lambda to define a function. Syntax:
Alias_name = lambda [parameter_list]:expression
Where, Alias_name is the alias for the part after the =, and the lambda can have and only have one expression after : .
- Functions of the lambda expression.
- As the return value of a function.
- As the arguments of a function.
Lambda is suitable for defining those function disposal after using.
- Some notes.
map(function, iterable)indicates the function to handle iterable's each element, and then yield a result with a type of map, which can be transferred to the type of list.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.D.4 >
读书 自学是门手艺 学时:8月17日 Day38 30 mins
学习内容:Part.2.D.4 Recursion
- The definition of Recursion
Calling the function inside the function itself.
For the understanding of the recursion.
def function():
if stop condition() is true:
pass
return # the result of the most simple condition #
else:
return #call the function() in other more complicated condtions that would step to the stop condtion #
- Recursion must have determination.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.D.5 >
读书 自学是门手艺 学时:8月18日 Day39 30 mins
学习内容:Part.2.D.5 Docstrings
- The docstring is the note that introduces other how the methods implement their functions.
""this is the docstrings"""
Docstrings must be declared at the beginning of the inferior function block, and also keep the rule of indention.
The docstrings can be checked by help() and .__doc__ methods.
- Some codes need to be followed when writing docstrings.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.D.6 >
读书 自学是门手艺 学时:8月19日 Day40 40 mins
学习内容:Part.2.D.6 modules
- Modules
If a file with a name like Module.py, this file can be regarded as a module.
%load Module.py can load the file to a cell of Jupyter.
-
import Module
The order to finding the Module. First, search built-in modules, and then find the sys's returning files.
- How to use functions in a Module, such
function()is defined in the file ofModule.
The first way, using import Module then Module.function() to call the function.
The second way, using from Module import function, then use function() directly.
- Import modules from package, such as a
Module.pyin the package ofPackage.
from Package import Module or
import Package.Module
- Using alias to indicate specific modules, such as a
function()defined in the file ofModule.
import Module as m (use m to indicate Module).
from Module import function as f(use f to indicate function())
-
The other parts besides functions in a module can also be imported.
-
dir()can be used to check the values and functions of a specific module.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.D.7 >
读书 自学是门手艺 学时:8月20日 Day41 40 mins
学习内容:Part.2.D.7 tdd
-
Test-Driven Development(TDD) This is a thought that backward reducing the process of a function by test the output of the function.
-
Syntax errors and runtime errors Syntax errors mean codes do not meet the syntax requirements.
Runtime errors are exceptions that would happen when running the code.
To solve the exceptions:
try:
do something()
except built_in_error as alias:
do something()
...
except built_in_error2 as alias2:
do something()
else:
do something()
finally:
do something()
```
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.D.8 >
读书 自学是门手艺 学时:8月21日 Day42 30 mins
学习内容:Part.2.D.8 main()
- The method to use main().
We write functions or modules, and then define a main() function. This main() function is used to call other related modules, and implement them under this main() function. At last, using the following codes to call the main() function.
if __name__ == '__main__':
main( iteratable,...)
- The objectives of this method.
If we don't call other modules under the function of main(), when importing the modules directly, those modules would run straightforward.
However, if we use the main() method, when importing the modules, those modules would not run and just be called.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.2.E>
读书 自学是门手艺 学时:8月22日 Day43 30mins
学习内容:Part.2.E. deliberate-thinking
The deliberate practice is the method we get familiar with new stuff. But before this, we need to know which stuff is required to handle. The thinking for this part is that so-called deliberate thinking. To be more specific, when thinking the question that where the knowledge we learning can be used we are doing the deliberate-learning.
After deliberate learning, we need to re-organize our thoughts and remove redundant things. And then practice the remaining things and put them into practice.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.3.A>
读书 自学是门手艺 学时:8月23日 Day44 30mins
学习内容:Part.2.A. Conquering difficulties
This part motivated me since I have some relative feelings about that.
When I get started learning something, I often find that what facing me is hard and makes me anxious. At that moment, I do not know how to handle it, and maybe I will choose to give up.
To solve this question, a good way is to disassembly the big project into small parts, and then conquer those small parts one by one.
In practice, I need to get a deep insight into that project and then make a feasible plan for the detailed parts split from the project.
One example of this process is when reading a book to learn something. We need to persist to read out the whole book although during the process we cannot understand all content. Then, we need to repeat to read and learn it until we achieve a good effect. During this, we should do inducing, organizing, summarising for the content, which would help us understand and think deeply.
学员信息
- 学号:<1901050136>
- 学习内容:<自学训练营自学7群>
- 学习用时:<自学是门手艺 Part.3.B.1>
读书 自学是门手艺 学时:8月24日 Day45 30mins
学习内容:Part.3.B.1.Classes-1
The OOP is one thought of developing projects in programming, and this is one kind of many different languages, including Python.
The Class is the concept that a module is defined to abstract one kind of something, it has attributes and methods. And objects are the instance of the classes. Classes have their subclasses, which inherit their superclasses attributes and methods and also have their attributes and methods.
When we using this kind of thought--OOP, we need to have the strong ability of abstraction.