Summary
The Introduction to Python module is designed for detection engineers and cybersecurity professionals new to Python, Cybersecurity analysts looking to integrate Python for threat detection, Incident responders seeking foundational Python knowledge, and IT professionals interested in leveraging Python for cybersecurity. Throughout this module, students will develop introduction to Python syntax and fundamental programming concepts and an understanding of basic data structures and their application in Python.
Recommended prior knowledge:
- No prior experience in Python required; the module is suitable for beginners
Introduction to Python
What is Python?
Python is a general-purpose, high-level programming language with an easy-to-learn and readable syntax. It was created by “Guido van Rossum” in 1991 and is widely used in artificial intelligence, machine learning, web development, data analysis, automation fields and many more.
Python is a language that is easy to learn and with which you can quickly start developing applications. But like all languages, it has its own Syntax, Operators and Standard Data Types. Let's examine what these are:
Python Syntax
-
Python code continues until the end of the line, it does not need a special end-of-line character (for example, ';').
-
In Python, blocks (functions, if else blocks, loops, etc.) are defined by indentation. This indentation is usually made with a tab or 4 spaces.
-
Python is a case-sensitive language, for example, 'Variable' and 'variable' are considered two different variable names.
-
Comment lines begin with the '#' character and are not interpreted by Python.
Operators in Python
As in all languages, various operators are used for various operations in Python. Learning all these well and knowing their functions is the basic information we need to develop working Python scripts:
Arithmetic Operators
Arithmetic operators are operators with which we can perform arithmetic operations in Python, and they have very simple and understandable syntaxes:

Assignment Operators
Assignment operators are used to assign a value to a variable. Normally, = is sufficient to assign a value to a variable, but Python also offers us some convenience during assignment. In this way, we can easily perform some arithmetic operations while assigning a value to the variable or changing its current value:

Comparison Operators
Like all programming languages, Python provides operators to compare two values. We can use the following operators to see the status of two different values relative to each other. The result of these operators always returns a boolean type data (true or false, 1 or 0).

Logical Operators
Python supports the following three basic operators for logical operations:

Bitwise Operators
Bitwise operators are available in Python to perform bitwise operations:

Identity Operators
In Python, we use identity operators to understand whether the two values we have represent the same object. There are 2 identity operators as follows:

Membership Operators
Python has membership operators to check whether a value is in a particular collection (list, tuple, set, dict, str):

Data Types in Python
Python is a very powerful language when it comes to data types and by default it supports almost all data types we may need while coding. In cases where these are not sufficient, it provides very easy support for us to define our own data types and then use them:

We'll cover defining and using our own data types later in the module.
In this part of the training, we have briefly covered what Python is, its syntax, operators and data types. We will learn about the Establishing the Python Environment-1 topic in the next part of our training.