DEV Community

Cover image for Python 101: Your Complete Beginner's Guide from Setup to Running Programs
Erick Mweri
Erick Mweri

Posted on Edited on

Python 101: Your Complete Beginner's Guide from Setup to Running Programs

Introduction

Python is a programming language. A programming language is a way of giving instructions to a computer. Python is popular with beginners because it is easy to read and free to use. People use it for data analysis, building websites and automating tasks.

In this guide, I take you step by step from installing Python to running your first programs using a Windows computer.

All the code and screenshots in this article are in my GitHub repository. You can copy the code and run it yourself.

Step 1: Install Python

The simplest way on Windows is the Microsoft Store.

.Open the Microsoft Store and search for Python 3.13.
Click Get and wait for the installation to finish.

.You can also download Python from python.org. If you do, tick Add python.exe to PATH on the first screen, so your computer can find Python later.

Step 2: Check that Python is installed

Press the Windows key, type cmd and press Enter to open Command Prompt. This is a black window where you type commands, also called the terminal. Type this and press Enter:

python --version

You should see a version number, such as Python 3.13.1. That means Python is installed and ready. If you see an error saying 'python' is not recognized, install Python again and make sure it is added to PATH.

Step 3: Choose where to write your code

python is a language as said above so we have to right it.
we will use three tools .
1.VS Code is a free code editor which we download from Microsoft store, helps to write code and easily spot mistakes.
2.Jupyter Notebook lets you write code in small blocks called cells. You run one cell at a time and see the answer right below it. This is great for learning, because you can test one idea at a time.
3.Google Colab is a Jupyter Notebook that runs in your browser. You install nothing, so it is a good backup if your computer gives you trouble.

To set up VS Code, open it and click the Extensions icon on the left side. Search for Python and install the one from Microsoft. Then search for Jupyter and install that too. These two extensions let VS Code understand Python and run notebooks.

Step 4: Create a project folder and a notebook

Good habits start early, so keep each project in its own folder.

Create a new folder on your desktop called python-101.
In VS Code, click File, then Open Folder, and choose python-101.
Click the New File icon and name the file python_101.ipynb. The ending .ipynb tells VS Code that this is a Jupyter notebook.
When the notebook opens, click Select Kernel at the top right and choose Python 3.13. The kernel is the engine that runs your code.

A notebook has two kinds of cells. Code cells hold Python, and Markdown cells hold notes. Click + Code to add a code cell. To run a cell, press Shift + Enter.

Step 5: Run your first program

Type this in a code cell and run it:

python
print("Hello, World!")

You will see:

Hello, World!

print() is a function. A function is a ready-made tool that does one job, and this one shows text on the screen. The brackets hold what you give to the function, and the quotation marks tell Python that Hello, World! is text.

You just wrote and ran a Python program. Everything else is built on this same idea: you write instructions, and the computer follows them.

Step 6: Variables, the way programs remember things

A variable is a name that stores a piece of information. Think of it as a labelled box.

python
name = 'erick'
county = 'nairobi'
fee_balance = 30000
is_paid = True
print(name, county, fee_balance, is_paid)

The output is:

erick nairobi 30000 True

The = sign does not mean "equals" like in maths. It means "store this value in this name". Here, name holds text and fee_balance holds a number.

Rules for naming variables

Use only letters, numbers and underscores.
1.A name cannot start with a number. sale_2026 is fine, but 2026_sale is an error
2.No spaces. Use an underscore instead, like fee_balance.
3.Names are case sensitive, so Name and name are two different variables.

Step 7: Changing variables

Reassigning a variable. You can give a variable a new value at any time. Python works out the right side first, then stores the answer back in the same name.

python
sale_2026 = 900000
sale_2026 = sale_2026 + 400000 # 400000 is the unbooked sale
sale_2026

The output is 1300000. The old value, 900000, was replaced.

Multiple assignment. You can create several variables in one line:

python
tax_rate, commission = 0.36, 0.29

Swapping values. Python can swap two variables in one line, with no extra variable needed:

python
tax_rate, commission = commission, tax_rate
tax_rate

The output is 0.29, because tax_rate now holds the value that commission had.

Step 8: Data types and typecasting

Python has four basic data types:

String (str): text inside quotes, like 'erick'.
Integer (int): whole numbers, like 30000.
Float (float): numbers with decimals, like 1.75.
Boolean (bool): either True or False, with a capital first letter and no quotes.

You can check a type with the type() function:

python
print(type(name)) #
print(type(fee_balance)) #
print(type(1.75)) #
print(type(is_paid)) #

Typecasting means changing a value from one type to another. This matters because "85" in quotes is text, not a number, and you cannot do maths with text.

python
score_text = "85"
score_number = int(score_text)
print(score_number + 5) # 90
print(str(30000) + " shillings")
print(float("1.75"))

Use int() for whole numbers, float() for decimals and str() for text.

Step 9: Working with strings

Concatenation means joining strings together with the + sign.

python
first_name = 'judas'
last_name = 'mweribum'

full_name = first_name + last_name
full_name # 'judasmweribum'

full_name = first_name + " " + last_name
full_name # 'judas mweribum'

The first version has no space between the names. Adding " " in the middle fixes that.

Indexing means picking one character from a string by its position. Python starts counting at 0, not 1.

python
county = 'nairobi'
print(county[0]) # n
print(county[3]) # r
print(county[-1]) # i (a negative number counts from the end)

Slicing means taking a piece of a string. You give a start and a stop. The start is included, but the stop is left out.

python
print(county[0:3]) # nai
print(county[3:]) # robi

Step 10: Input and output

Output is what your program shows, and print() does that. Input is what the user gives your program, and input() does that.

python
name = input("What is your name? ")
print("Nice to meet you,", name)

When you run this cell, VS Code opens a box at the top of the window. Type your answer and press Enter. One important thing: input() always gives back text. To do maths with what the user typed, convert it first.

python
age = int(input("How old are you? "))
print("Next year you will be", age + 1)

Step 11: Arithmetic operators

Python works as a calculator. The symbols it uses are called operators.

Operator Name Example Result

  • Addition 9 + 2 11
  • Subtraction 9 - 3 6
  • Multiplication 9 * 3 27 / Division 9 / 2 4.5 % Modulus (the remainder) 9 % 2 1 ** Power 9 ** 2 81 // Floor division (no decimals) 9 // 2 4

The remainder is what is left over after dividing. Nine divided by two leaves a remainder of one, because two goes into nine four times, which uses eight.

Practice question

Write a program that asks for a student's name and the amount of fees paid, then shows the balance. The total fee is 50000.

python
name = input("Student name: ")
fee_total = 30000
amount_paid = int(input("Amount paid: "))
balance = fee_total - amount_paid

print("Student:", name)
print("Balance:", balance)

This one uses input, typecasting, a variable and an operator, which is most of what you learned today.

Common mistakes and how to fix them

Syntax Error: you forgot a bracket or a quote. Check the line Python points to.
NameError: you spelled a variable wrongly, used the wrong capital letters, or forgot to run the cell that creates it.
TypeError: you tried to add text and a number. Convert with int() or str().
'python' is not recognized: Python is not on your PATH. Reinstall it and tick the PATH box.
Nothing happens in a notebook: you may have forgotten to run the cell. Press Shift + Enter.

Read error messages from the bottom up. They usually tell you exactly what went wrong and on which line

Conclusion

You now know how to install Python, set up VS Code and Jupyter, and run your own code. You have worked with variables, data types, typecasting, strings, input, output and operators. Those are the building blocks of every Python program.

Every line of code in this article is in my GitHub repository, so you can copy it and try it yourself.

Top comments (0)