Have you ever thought about being one of those cool hackers on TV and movies who can bring down NASA with a few lines of code while licking a lollipop, or ‘stick’ candy?
This tutorial series will probably not make you into one, but you’ll be sure to be on the journey there, so stick around (and just a heads up, hacking NASA is illegal).
First, what is Python?
No, it’s not a constricting snake.
Python is an interpreted, high-level programming language created by Guido Van Rossum. It was actually named after ‘Monty Python’, a British-based comedy group which was quite popular in the ‘70s, and even has some fans in present day.
Okay, slow down. Interpreted? High Level?
Basically, an interpreted programming language is one which is run directly without having to be compiled down to machine-understandable code. The code is executed using the language’s own interpreter which has to be installed on the machine.
Think of it as speaking English to a French-speaking man and having one of your friends, who understands both languages, translate for you.
A high-level programming language is one that doesn’t bore you with all the geeky details of programming like how much CPU memory to use. It instead automates the significant aspects and lets you focus on actually creating your program and usually uses elements of actual human language (you know, like for-loop instead of 00101001010).
Phew! So, enough with all the history of Python. Let us jump into writing some actual code.
First, you need to grab the Python interpreter from the Python download page (you really don’t want to speak to a French person without your interpreter friend). It’s pretty easy to install, just follow the instructions on the website for your specific operating system.
I’ll be using the Microsoft Windows OS for this tutorial, by the way. The installation on a Mac is quite different, but it isn’t complicated.
In Windows, do make sure to check the ‘Add to PATH’ option when installing, this is to ensure you can access the interpreter from the Command Prompt.
After installation is complete in Windows, open up the command prompt and type ‘python’. You should see the screen below.
If an actual Python snake comes out of your screen or if you see ‘python’ is not recognized…”, you probably installed it wrong. Reinstall and try again (be sure to follow instructions) and you should be fine.
Mac Os Installation
Head over to http://brew.sh and copy the command under the ‘Install Homebrew’ segment of the page.
Open up the Terminal App, paste the code and run it. It will request you to enter your user account password. Do that and finalize the installation. You need to be connected to the internet for homebrew to download all the required files.
As soon as the installation is done, head over to the Terminal and type the following command, brew install python3. This will install Python on your Mac. When the installation is done, type ‘pip3’ and hit Enter, you should see Python’s Pip Help Text.
Now, let’s get to some actual code.
Printing Hello World and Code Editors
Type the following into your interpreter, print(“Hello World!”), and see the magic.
Arise, Ser ‘Your Name’, Knight of the Python Kingdom!
Text editors are awesome software that make writing code easier and honestly geekier. I use Visual Studio Code, but there are tons of options out there. Do some research and choose whichever looks pretty to you.
When you’ve picked one (hopefully, it was Visual Studio Code), create a folder for this tutorial, and open that folder in your code editor.
Open a new file, and type the code you earlier typed in the interpreter in the file you created and save it as ‘hello.py’.
Head over to your file explorer and run it, you should see the command prompt blink. Don’t worry, your code worked.
But why did it blink? You’ll find out in the next chapter.
I do hope you learned something from this tutorial.
Feel free to contact me if you have any questions or comments.
Cheers, and welcome to Python programming, Ser Your Name.