DEV Community

Emmanuel Kariithi
Emmanuel Kariithi

Posted on

PYTHON 101: ULTIMATE PYTHON GUIDE

Have there been instances where you were hanging out with your tech buddies, as we like to call them, ‘tech bros’ they start talking about python this and python that? You are just there wondering why are people who don't specialize in veterinary services talking about a snake? Did you feel out of place? (This intro feels like I am trying to market something. I will stop there).

The purpose of this article is to guide you (in a technical and yet not so technical way) on how to install, configure, write your first python program and run it. We first have to understand what Python is. No, not the snake.

Overview

Python is a high-level programming language released in 1991 created by Guido van Rossum. Python has a relatively simple syntax compared to other programming languages e.g. C++ and has countless use cases. Here are a few of them;
1. Artificial Intelligence
2. Desktop Application
3. Automation
4. Web Development
5. Data Wrangling, Exploration And Visualization.

Python has a couple of features, including but not limited to;
1. It is simple to write and run.
2. It is open source
3. It is Portable.
4. It is embeddable & extensible.
5. It has a huge collection of libraries.
6. It is object-oriented.

Setting up your Python Environment

The installation process is pretty simple. I'll guide you through the installation process for those using Ubuntu. I will leave some links to guides on how to install on Windows and Macs.
1. Head over to the python website download page.
2. Here’s the link: Python
Python Download Page
3. Select the release you want.
4. You can either choose to download the latest version (3.10.2) or scroll down and choose an older version. I chose version 3.8 for this installation.
5. Install Python
You can either use the downloaded file to install Python or use the terminal. I prefer using the terminal since it is easier.

Below is a step by step guide for installing Python using the terminal.
1. Run Sudo apt install python3. Follow the instructions given (Input password and type Y to continue).
Install Python3
2. Run Sudo apt install python3-pip (Follow the instructions given on the terminal).
Install Pip3
3. Run pip3 or python3 --version to confirm that the installation was successful.
Confirm Pip Installation
Confirm Python Installation

Done. See how easy it is?
Windows Installation
Mac Installation

Write your first Program

I bet you feel like a real programmer now? Me too, I think it's time to start applying to those freelancing gigs on Upwork? Not so fast.

Let us write our first program, the usual ‘Hello World program’. We are going to use visual studio code. You can also use the normal notepad.

  1. Open visual studio code and open a new text file. Open VS Code
  2. There are two ways in this step, you can either click on ‘select a language’ if you are using visual studio or directly save the file and edit the .txt extension to .py. Save File
  3. Now we are finally here, the best part about programming, writing the code. Your first line of code (if you are a total beginner, give yourself a clap). As stated earlier, python has a pretty simple syntax, however, we will only write one line of code to display hello world. Unlike languages like C++ which requires multiple lines to display this simple greeting.

On the opened file, type print("Hello World") or print('Hello World'). Then click F5 for those working on visual studio.
Python does not care if you use the single quotes or double quotes, unless what you want to display has quotes in it e.g. print("It's finally happening, I'm writing my first technical article").
Python Hello World

Finally, you can ask the user of your program to input certain details by using the input function and later print what the user inputs.
print(input("What’s your name? ")).
Python Input

That’s it for today. I hope this article has helped you in one way or the other. Feel free to leave feedback on what to improve on. I hope to write more on my programming journey.

Resources

  1. Python Youtube Course

Oldest comments (0)