How do I learn Python?
这篇文章摘自Quora,讲的是如何学习Python。给我最大的收获不是教我如何去学习Python,而是那句“找到是什么在激励着你”)(Find what motivates you),学习本身应该也算是一种享受了。动机是关键的所在,找到自己的学习动机,自己驱动着自己保持学习下去。
正文:
The most important question to answer first is why do I want to learn python? Answering this will guide what you use to learn and how you learn.
Starting with a very generic list of resources to learn python when you eventually want to make websites (for example), will not only reduce your motivation, it will also make it much harder to apply the knowledge you gain. I‘ve tried to learn coding without context and application, and I‘ve almost never come out of it with any meaningful skills.
When I learned python 3 years ago, I wanted to create websites. It shouldn‘t come as a shock to anyone that the best way to learn how to do this was to create websites.
1. Find what motivates you
Finding and keeping your motivation is key -- I slept through a lot of the one high school programming class I took because it made us memorize a bunch of syntax. On the other hand, when I needed to learn python to make an automated essay scoring algorithm, I stayed up many late nights learning and iterating.
Motivation is rarely addressed in learning -- you‘re often just given a list of generic tutorials to try, and told to go do them. But the great thing about python is that you can develop almost anything, from mobile apps to games to advanced machine learning algorithms. No matter what you‘re interested in, you can probably build it in python, and there‘s probably a good getting started tutorial.
Pick an area or two that you‘re interested in, and stick with them-- you‘ll be developing quite a few projects in the areas.
Here are some sample areas, but feel free to add your own:
- Websites
- Mobile apps
- Games
- Data science/Machine learning
2. Learn some basic python syntax
Unless you know the basic syntax, it‘s hard to implement anything. That said, don‘t spend too long on this. The goal is to learn the very basics, so you know enough to start working on your own projects in your areas(s) of interest.
For reference, I spent less than a week on codecademy, and went through about 30% of the material. This was enough to get started on a project.
Some resources that can help you:
- Codecademy -- does a good job of teaching basic syntax.
- Learn python the hard way -- a book that teaches a lot of python concepts.
- Dataquest.io -- this is my startup. It‘s focused on teaching python for data science, but it teaches all the basic syntax also.
- The Python Tutorial -- the tutorial on the main python site.
I can‘t emphasize enough that you should only spend the minimum amount of upfront time possible on basic syntax. The quicker you can get to working on projects, the faster you will learn. You can always refer back to the syntax when you get stuck later.
3. Make structured projects in your chosen area
Unless you actually apply your knowledge, you won‘t be able to retain it well. Projects are a great way to learn because they push your capabilities, show you how to apply skills, and give you a portfolio to show employers in the future.
When you start out, it can be helpful to have more structured projects with some guidance. Here are a few ideas:
Games
- Codecademy -- walks you through making a couple of simple games.
- Pygame tutorials -- pygame (the python library for making games) has a good list of tutorials
- Making games with pygame -- this book looks like a great way to learn python by making games
Websites
- Flask tutorial -- the official flask (simple python web framework) tutorial.
- Bottle tutorial -- Bottle (even simpler web framework for python) tutorial.
- How To Tango With Django 1.7 -- a guide to using django (more complex python web framework)
Mobile apps
- Kivy guide -- Kivy is the tool that lets you make mobile apps with python. They have a guide on how to get started.
Data science
- Dataquest.io -- Teaches you python and data science interactively. You analyze a series of interesting datasets ranging from CIA documents to NBA player stats.
- Scikit-learn documentation -- Scikit-learn (the main machine learning library for python) has some great documentation and tutorials.
- Python for Data Analysis -- written by the author of a major python data analysis library (pandas), it‘s a good introduction to analyzing data in python.
4. Work on projects on your own
Once you have learned the concepts in a guided manner, it‘s time to work on some projects on your own. You‘ll still need to consult references and look up concepts, but you‘ll be fitting what you learn into the needs of your project, not the other way around.
Finding other people to work with here can both help you learn and help keep you motivated.
Some ideas:
- Extend the projects you were working on previously, and add more functionality.
Go to python meetups in your area, and find people who are working on interesting projects.
- Find open source packages to contribute to.
- See if any local nonprofits are looking for volunteer developers.
- Find projects other people have made, and see if you can extend or adapt them.
My first project was adapting my automated essay scoring algorithm from R into python. It didn‘t end up looking pretty, but it started me on the journey to learning python.
The key is to pick something and do it. If you get too hung up on picking the perfect project, there‘s a risk that you‘ll never make one.
5. Keep working on harder projects
Keep increasing the difficulty and scope of your projects. If you‘re completely comfortable with what you‘re building, it means it‘s time to try something harder.
Here are some ideas for when that time comes:
- Try teaching a novice how to do your current project.
- Try load testing your website -- can you scale it up?
- Can you make your program run faster?
Going forward
At the end of the day, python is evolving and changing all the time. There are probably only a few people who can legitimately claim to completely understand it.
You‘ll need to be constantly learning and working on projects. If you do this right, you‘ll find yourself looking back on your code from 6 months ago and thinking about how terrible it is. If you get to this point, you‘re on the right track.
Python is a really fun and rewarding language to learn, and I think anyone can get to a high level of proficiency in it if they find the right motivation.
原文地址:https://www.cnblogs.com/crb912/p/9179415.html