Python for Beginners
Completely new to programming? Fret not, we got you covered. As you can guess, first we would need to set up an environment to get started. We would need to install a text editor to write the code and install python to run the code.
Of course, you can write code in a vanilla Notepad file. While this is good to begin with, it's going to make your life very hard very soon. Here is why,
- No Syntax Highlighting - Yes, you don't see colored text for reserved words, and this is perhaps the biggest problem. You will end up making tons of mistakes making life miserable.
- No Autocomplete - Modern text editors have an autocomplete feature that autocompletes variable names and reserved words. This makes coding faster and less erroneous.
- Lack of Formatting - Notepad will not auto-indent the code for you when you start writing a block. Indentation of code makes it more readable, and in fact, is necessary while writing Python codes
All this makes us jump to better text editors. We recommend using Notepad Plus Plus, Sublime Text, Visual Studio Code(most of us use this) or a dedicated IDE (Integrated Development Environment) for that language. As a beginner, Sublime Text is recommended.
If you're using Ubuntu, open terminal and execute
sudo apt-get install python3.
If you're using MacOS, open terminal and execute
brew install python3.
If you're using Windows, follow these steps -
- Download the installer here
- Execute/open the downloaded
- On the first screen, enable the “Add Python 3.6 to PATH” option.
- Click Install Now.
- Make sure to disable PATH length limit.
Now open up terminal, type
python (for Windows) or
python3 (for Ubuntu/MacOS). If there's no error message, you're good to go!
Let's get started with the coding part.
- Automate the Boring Stuff is a classic yet excellent resource for beginners. While we recommend you to read the book, you can also follow the video tutorial. Read and follow along the first 2 chapters, to understand some basics like variables, conditional statements, and loops. You can read Ch 0 for some motivation as well. Although they recommended using Mu, you can use the interactive shell of your terminal as well. To run a python file, from your terminal go to that file's directory, and type
- Go through the 1st Part (Primitive Datatypes and Operators) of this website to quickly revise what you have learnt. Execute all the commands in interactive mode to understand things more clearly.
- Time to practice what you've learnt! Try solving these super easy questions - Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14. Although some of them are too simple, I'll recommend solving each one of them, because programming is all about practice :)
- Now, read the next 2 chapters of Automate the Boring Stuff. Ch3 covers Functions and some of their essential properties. While, Ch4 covers Lists. If you know about Arrays in C++, lists are very similar to them, just with added functionality.
- Let's practice some questions related to applications of lists/arrays - Q1,Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9.
- Now read Ch5, which covers Dictionaries. There are interesting implementations in this chapter, make sure to do all of them.
- Now, go through Parts 2-5 of Learn X in Y minutes. Obviously, run all the codes by yourself to verify the results.
- Ch6 covers Strings and string operations. The projects given are excellent for gaining clarity on working with strings.
Not a Newbie anymore
If you successfully read and implemented all the content covered above, you are ready to move on to the next level. But before that, you should go through Software Development, for an advice on some good programming practices. Because remember, being able to solve a problem isn't sufficient. Your code should be understandable and sturdy. These practices should be inculcated from the beginning so that you don't have problems taking them up later on. Also, Part 6 of Learn X in Y minutes is a foundation for the next level. Go on, now go to Intermediate Python Programming, for you are a coder now.