The real world of python learner: you may have only 30 min per day to learn Python programming. It is quite often that sometimes you may not have no time at all. When you have time to go back where you left, you will find you forget everything. Because of the working load, family duties and other unexpected staff to deal with, you can be still at the entry level after a year of learning and have to start over again.
This tutorial is to help you to break the strange cycle and really improve your programming skill through the journely of mastering Python.
First, I want to mention something important, but you may not pay attention to before reading this tutorial.
-
Active vs. Passive learning
Active learning is to explore this field by yourself. You keep asking yourself questions and try to find the answer over internet and take notes.
Passive learning is to follow the teachers to learn what you should learn, but do not ask why you should learn.
-
The framework of Knowledge is more important than the Knowledge itself.
The framework is the basic structure of a course or field. It is quite obvious for the people with special training in the field. However, if a layman want to learn this field by himself, to build the framework is the most important part.
To do this, try to focus on some simple books with knowleges well organized. I may also want to follow this post. The aim of this post also try to build the framework, but at the same time I will point out the difficult and important knowleges for python programming.
-
The best website to learn python (highly recommend)
create an account on https://stackoverflow.com
This is a website you will visit everyday. This is an important website to ask any question. The answers are usually already there.
The only thing you need to do is Google your question.
Then have their clippers installed to your web browser. If you find your anwser on web, save it by the clippers
At the begining, you may just write down some keywords in your brain. later on, you will write down the knowledge tree to show the
connections of the key words to each other.
"Everything is an Object." --- Don't be fooled. That just means using "." in your code. Forget object now.
Two books: "PFundamentals of Python Programming" and "An introduction of computation and programming in python".
First, find a piece of code online, then type in all the lines on your computer, and check the results. Yes, just copy others' codes. During copying, you will gradually understand the logic behind it. Don't just copy and paste, actually type all the code by yourself.
- list: list slice
- array: array slice, multi-dimension arrays
- dictionary: easy to use, not important
- string: the most hard part, please learn how to use regular expression.
- The common mistakes here is the indent, which affect the scope of a loop. It is easy to make a loop run forever by a mistaken indent.
- Get confused by the scope of variables outside a function and inside a function.
- string is hard to master at this stage. this part include lots of manipulation of string, which is quite common in daily work.
At this section, please read the book, "Python for Data Analysis".
-
Jupyter Notebook Everybody uses it.
-
Pycharm Very good ide but it can easily slow down my i7 workstation
-
Vscode Lightweight, but powerful. recommend
-
Emacs The only drawback of Emacs is too much power. It is such a powerful editor that people find it hard to handle. We only want to drive a car to New York, it gives us an airplane. It will take 5 years to learn to fly, but we only need 5 months to learn driving a car.
A code snippet or a big applications can be divided into small pieces with each piece realzing a small function. Like lego, put the small pieces together.
- First, write down the goal
- Second, draw a flow chart of how to realize it
- Third, identify the function to be realized.
You do not need to realized all the functions at once. Instead, you can pretend others are finished, just focus on one function each time and test each function when finished. Then put them together.
Put some TODO label in the code when you write the code. Some important ideas come when you actuall write code.
3. Add code headers to show the authors, date created, purpose the code, variables, notes, copy right, coding (UTF-8) etc.
6.1 Always has a timestamp for the results. Otherwise, the saved results can be overided when run the code multiple times.
6.2 Give a consistent name for the file. It is good to include to include some global variables to the name.
Programming is like building Legos. You have lots of building units and use them to make a castle, car or anything you think is cool. But the building units are the same. Programming follows the same logic. So what's the building unit for Python programming?
The bulding blocks are the samll functions to realize something specific. For example, we need to get a list of files with their absolute paths. We will create a simple function to realize it or you find it on Overflow. Write it down as your reference in the future. You need to come back to review it and make it better when you need it in your projects.
A good starting point is to read a book, "Python Cookbook" and digest it and take your notes for future use.
I found this part is the hardest one. People get scared away by the strange names like, self, init, etc.