Python for Absolute Beginners

A Quick Guide

Christopher Franklin
Weekly Python
2 min readApr 21, 2023

--

Introduction:

Python is an extremely versatile programming language that has gained immense popularity in recent years. Its readability and simplicity make it an excellent choice for beginners. If you’re looking to dive into the world of programming, you’ve come to the right place. In this comprehensive guide, we’ll introduce you to Python and help you take your first steps as a programmer.

Installing Python:

To begin, you’ll need to have Python installed on your computer. Visit the official Python website (https://www.python.org/downloads/) and download the latest version. Follow the installation instructions for your operating system (Windows, macOS, or Linux).

Running Python:

Once Python is installed, you can run it in different ways:

  • Interactive Mode: Open your terminal or command prompt and type “python” (without quotes). This will start Python’s interactive mode, allowing you to type and run Python code directly.
  • Script Mode: Write your code in a text editor, save it with a .py extension (e.g., hello.py), and run it by typing “python filename.py” (without quotes) in the terminal or command prompt.

Python Basics:

Now that you have Python set up, let’s dive into some basic concepts.

Variables: Variables are used to store data in Python. To create a variable, simply assign a value to a name:

name = "Alice"
age = 25

Data Types: Python has several built-in data types, such as integers (int), floating-point numbers (float), strings (str), and booleans (bool):

x = 5 # integer 
y = 3.14 # float
z = "Hello" # string
b = True # boolean

Basic Operations:

Python supports various arithmetic, comparison, and logical operations:

Arithmetic: +, -, *, /, ** (exponent), % (modulus), // (integer division) Comparison: <, >, <=, >=, ==, != Logical: and, or, not

Control Structures:

Control structures help you execute code based on certain conditions or repeat code multiple times.

If, elif, and else: These statements allow you to execute code based on a condition:

x = 10 

if x > 5:
print("x is greater than 5")
elif x == 5:
print("x is equal to 5")
else:
print("x is less than 5")

Loops: Python has two types of loops — for loops and while loops:

for i in range(5): 
print(i)
x = 0 

while x < 5:
print(x)
x += 1

Functions:

Functions are reusable blocks of code that perform a specific task. You can define your own functions using the “def” keyword:

def greet(name): 
print(f"Hello, {name}!")

To call a function, simply use its name followed by parentheses:

greet("Alice")

Conclusion:

This guide is just the beginning of your Python journey. As you continue to learn and practice, you’ll discover the power and versatility of Python. Remember, the key to becoming a proficient programmer is persistence and dedication. Keep learning, experimenting, and challenging yourself to become the best Python developer you can be.

Happy coding!

--

--