How to Code in Python: A Guide in PDF Format

Python is a high-level programming language that is widely used in the world of coding. It is an easy-to-learn language that is popular amongst both beginners and experienced programmers. Python is well-known for its readability and simplicity, and it is an excellent choice for anyone starting to learn coding.

If you are looking to learn how to code in Python, this guide is for you. In this article, we will provide you with a comprehensive guide on how to code in Python, in PDF format. We will cover everything from setting up an environment to writing your first Python program. So, without further ado, let’s get started.

Setting Up Your Environment

Before you begin coding in Python, you need to set up your environment. There are three essential components that you need to get started: the Python interpreter, a text editor, and the command line. Here’s how to set up your environment:

Installing the Python Interpreter

The first step in setting up your environment is to install the Python interpreter. You can download the latest version of Python from the official Python website. Once you’ve downloaded the installer, run it, and follow the prompts to install Python on your computer.

Choosing a Text Editor

A text editor is a program that allows you to write and edit Python code. There are many text editors to choose from, but some popular choices include Notepad++, Sublime Text, and Visual Studio Code. Choose a text editor that you feel comfortable with and install it on your computer.

Using the Command Line

The command line is a tool that allows you to interact with your computer through text commands. To get started with the command line, open the Terminal (Mac) or Command Prompt (Windows) on your computer. You can then navigate to the directory where you want to save your Python program.

Learning the Basics of Python

Now that you have set up your environment, it’s time to start coding in Python. Before you start writing your first program, you need to learn the basics of Python. Here are some of the fundamental concepts that you need to understand when coding in Python:


Variables are used to store data in Python. To create a variable, you need to give it a name and assign a value to it. Here’s an example:

my_variable = 10

In this example, we created a variable called my_variable and assigned it the value 10.

Data Types

In Python, there are several data types that you need to know. These include integers, floating-point numbers, strings, and Boolean values. Here’s an example of how to create each data type:

my_int = 10
my_float = 10.5
my_string = "Hello, World!"
my_bool = True


Operators are used to perform operations on variables and data in Python. There are several types of operators, including arithmetic, comparison, and logical operators. Here’s an example of each type of operator:

# Arithmetic Operators
my_sum = 10 + 5
my_difference = 10 - 5
my_product = 10 * 5
my_quotient = 10 / 5
my_modulus = 10 % 5

# Comparison Operators
my_equal = 10 == 5
my_not_equal = 10 != 5
my_greater_than = 10 > 5
my_less_than = 10 < 5
my_greater_than_or_equal_to = 10 >= 5
my_less_than_or_equal_to = 10  10:
    print("my_variable is greater than 10")
    print("my_variable is less than or equal to 10")

# For Loop
for i in range(0, 10):

# While Loop
while my_bool == True:
    print("Hello, World!")

Writing Your First Python Program

Now that you understand the basics of Python, it’s time to write your first Python program. Here’s a simple program that prints "Hello, World!" to the console:

print("Hello, World!")

To run this program, open your text editor and create a new file. Type the code above into the file and save it as Open the command line and navigate to the directory where you saved the file. Type python and press Enter. You should see "Hello, World!" printed to the console.


Python is an excellent language to learn for anyone interested in coding. It is easy to learn, and there are plenty of resources available to help you get started. In this guide, we have covered the basics of coding in Python, from setting up your environment to writing your first Python program.

Remember, coding takes practice, so keep coding and experimenting with different programs. With time and practice, you’ll be able to write more complex programs and applications. Happy coding!

Leave a Comment

Your email address will not be published. Required fields are marked *