Chat with us, powered by LiveChat

Teaching Yourself Python

So you’ve decided to teach yourself to code and are wondering where to start? In this article, I’ll convince you that teaching yourself to code is a great choice and that Python is a great first language to learn. I’ll also give you one possible path into the language.



You Should Learn How to Code


Being proficient in a programming language is becoming increasingly desirable as human interactions and operations move more into digital space. More specifically, if you are considering or are pursuing a career in STEM, you will be hard pressed to find a field that doesn’t value proficiency in a programming language. Even biological sciences rely on programs to run complex microscope systems, model biological processes, and solve other repetitive problems. Without a doubt, learning to code will increase opportunities available to you and likely make college a bit easier. Plus, coding is fun!


Moreover, if you want to go into computer science, many of your college classmates will already have years of programming experience. Many comp sci programs at top schools now have an unspoken expectation that students enter with some experience. Because of this, many schools have introduced computer science courses across all levels. In fact, high schools offering computer science courses have increased from 35% in 2018 to 51% in 2021, according to the 2021 State of Computer Science Education report by code.org. However, if you go to one of the nearly half of US high schools that doesn’t offer computer science, or maybe you just couldn’t fit it in your schedule, don’t fret! There are a ton of free resources available to help you learn to code.



Python as a First Language


Now that I have convinced you that programming should be your new exciting skill, why is Python a good place to start? First off, I want to emphasize that learning your first programming language is going to include a lot more than just the language itself. Unless you are really familiar with reasoning through problems with linear algebra and logic, figuring out what you want to tell the computer to do is going to take some time. Figuring out the right algorithm to specify your instruction is also one of the most rewarding parts of coding! This is the real critical skill that you are gaining by teaching yourself to code with Python. Once you master this in one language, you will be able to easily pick up other languages and transfer your logic and algorithm skills.


Python specifically is a great place to start because it is high level and has a wide range of applications. “High level” means the code is written in a way that is closer to how a user might think than to how the computer thinks. This means that Python is going to be easier to read and understand intuitively than lower level languages. Python is also an interpreted language, which means that it doesn’t have to be compiled before it is run. This means that you can run your code as you are writing it and see instantly if your logic is correct without having to compile the entire program. Overall, Python is a very user friendly language making it easy to learn.


In addition, Python is a versatile and popular language. It is really popular as the base of user interfaces and clients in more complex systems. You can program entire applications in Python or use Python for data analysis. Python likely can and is being used to solve whatever problems you are interested in. Python is even used by some tech giants as one of their official languages. Because so many people use Python, it is now very well documented and you will be able to easily find help when you get stuck. With its popularity and versatility, Python is a great language to know even if you never learn another.



Let’s Get You Started


Alright, let's get to the fun part.


First, you are going to need an Integrated Development Environment, IDE.


An IDE is a tool that you will use to write code which includes some tools like debuggers, etc. For Python, I recommend using Anaconda. It comes with Python and the Python specific IDE,  Spyder. Anaconda is great because it comes with a bunch of other tools that may be helpful to you as you continue on your programming journey. I also find the user interface to be intuitive and helpful. Some of the resources I talk about below use another IDE, PyCharm. I haven’t used PyCharm, but from what I have read, it is also very user friendly.


Now that you have an environment to program in, you are ready to start learning the syntax of Python.


This step, while important to being able to do anything, is the least interesting. You shouldn’t get too hung up on memorizing syntax, or learning every rule before you get started on some projects. You can always look up syntax. Python is one of the best documented languages, so the syntax is always just a Google search away. It is more important that you start to get a handle on the logic.


That being said, you should still dedicate some time to actually learning the basics. I recommend something around 3 hours if you are semi comfortable on the computer. Most of these courses use PyCharm and walk you through how to download it and get Python set up. You can still use these videos with Spyder (Anaconda). The interface might just look a bit different. This course from freeCodeCamp.org is a great starting point. As is this video from Amigoscode. If you feel more confident and want a very quick introduction to Python, you could try this video from Programming with Mosh, which is only an hour and doesn’t include as much intro to logic and examples that are worked through together. This is a good option if you learn much better through independent practice than guided example. On the other hand, if you feel like you want to take your time with the concepts and really get into several basic programming concepts and logic, this is a great 6 hour intro course from Programming with Mosh.


All of the above courses are going to offer a less structured learning environment and require you to figure out your own pacing and the amount of practice you need with each topic to feel comfortable. If you prefer more structured environments, there are many free online courses that stretch over weeks, like this one from Udacity.


You don’t really know Python, though, until you can command it to solve your problems.


Okay so you now have some vocab and grammar of Python in your toolkit, now it is time to actually write instructions for the computer. The best way to start to train your brain to think in a way that translates to instructing the computer is to start by solving some seemingly easy problems with Python. I suggest picking some project that you can easily predict the outcome so you can comfortably gauge whether your code is working. A great place to start is by trying to model simple games like this rock, paper, scissors program. This specific example comes with some template script that you can use or reference if you get stuck. Starting with examples that have the solutions available is a good place to start to just get familiar with how to structure algorithms and the types of solutions that you will be programming. The Python website offers a lot of beginner tutorials and this list also has several types of different projects so you can find one that suits your interests.


The point at this step is to develop a strategy that you can reliably employ each time you plan out your script. You are working to develop a familiarity with formats of information and how to store, locate, and use the information you are interested in. Once you have a general strategy for developing algorithms, you will be able to tackle a variety of different problems with Python.


Once you are comfortable with algorithms, you can start to do some really fun things with Python.


As I said earlier, Python is fun because of how versatile it is. Once you are ready, you can start to attempt to tackle much more interesting or prevalent problems with your Python programs. For example, you can solve a series of riddles with Python scripts on Python Challenge. Or if you are more into math and number based problems, you can start on the over 700 problems on Project Euler that have to do with calculating sizes of various mathematical sets among other challenging problems that can often be solved with simple code. These are great exercises if you want to go into software engineering as these types of problems come up as interview questions often.


Codecademy also has some very interesting projects that have more real world applications, like modeling honey production of bees. I found this list to also span several fields and applications of Python to give you some ideas of the power you now wield.


Happy coding!