Python for Cybersecurity _ Google Cybersecurity Certificate

Career World
1 follower
Comments are disabled for this video.
The process of learning a new programming language
is similar to learning a new language.
For instance, like any human language,
programming consists of words organized together
to form lines of code.
Lines of code are used to communicate with a computer,
similar to a sentence, telling it how to perform a task.
In this section, we're going to start learning
the language needed to communicate with a computer,
as we explore some key components of Python.
We'll start by introducing the basics of programming,
starting with why security analysts use Python.
Next, we'll start building the foundations for Python.
We'll discuss data types.
Then, we'll cover variables.
Lastly, we're going to learn about specific statements
we can make in Python, like conditional statements.
Conditional statements help us incorporate logic
into our programs.
The second type of statement we'll learn about
is the iterative statement.
Iterative statements allow us to repeat a line of code
multiple times without having to rewrite it.
Learning Python helped me succeed in my career
because using Python allows me to free up time
from repetitive tasks, and instead,
focus on more challenging tasks and problems.
Successfully applying automation
reduces my overall workload, increases productivity,
and reduces the risk of human error.
The use of automation also allows me to focus
on my engineering tasks, which require more creativity,
collaboration, and problem solving.
Are you ready to start programming in Python?
Let's begin.
Security professionals use a variety of tools.
One of those tools is computer programming.
Programming is used to create a specific set of instructions
for a computer to execute tasks.
Let's take an example of a vending machine.
Think of a vending machine as a computer
that supplies food or drinks to customers.
To receive an item, the customer inserts the money
into the machine, and then selects the item they want.
Let's say the customer provides the machine
with a value of $5.
The machine stores this value while you make your selection.
If you select a candy bar that costs $2,
the machine takes this input,
otherwise known as an instruction,
and then understands to output your candy bar for $2,
and provides the change back of $3.
There are many programming languages in existence.
Here, we'll focus on Python.
Python is considered to be a general purpose language.
This means that it can create a variety
of different programs, and it isn't specialized
in any particular problem.
In fields such as web development
and artificial intelligence,
Python is typically used to build websites
and perform data analysis.
In security, the main reason we use Python
is to automate our tasks.
Automation is the use of technology
to reduce human and manual effort
to perform common and repetitive tasks.
Python is generally best for automating short, simple tasks.
For example, a security analyst
who's dealing with a security incident
might have a log with necessary information.
Reading through this manually would take too much time,
but Python can help sort through this
so the analyst can find what they need.
As another example, an analyst might use Python
to manage an access control list,
the list that controls who can access the system
and its resources.
It would be potentially less consistent
if the analyst had to manually remove an employee's access
every time they left the company.
However, a Python program
can periodically monitor this instead,
or Python could also perform some automated tasks
like analyzing network traffic.
Though these tasks can be done through outside applications,
they are also possible through Python.
In addition to automating individual tasks,
Python can combine separate tasks into one workstream.
For example, imagine a playbook indicates
that an analyst needs to resolve a certain situation
by deleting a file
and then notifying the proper individuals.
Python can connect these processes together.
So why exactly might a security professional
choose Python for these tasks?
There are several advantages Python has
as a programming language.
For one, Python is user-friendly
because it resembles human language,
it requires less code, and it's easy to read.
Python programmers also have the benefit
of following the standard guidelines
to ensure consistency with the design
and readability of code.
Another great reason for learning Python
is that there's a large amount of online support.
Python also has an extensive collection of built-in code
that we can import and use to perform many different tasks.
These are just some of the reasons
why Python continues to be in high demand
across different industries throughout the world.
You'll most likely use it in your security career.
Now we'll practice writing and running code.
When we work in Python,
we refer to what we write as a script or a program.
There are subtle differences between the two.
Let's compare a computer program to a theater performance.
Almost every theater performance includes a written script.
Actors study and memorize a script
to say it out loud to an audience.
However, that's not the only component.
There's also the whole performance.
Directors make decisions on what kind of lighting to use,
or costumes, or what the stage looks like.
The performance as a whole involves a lot of design choices
like set design, lighting, and costumes.
The process of creating this production
is similar to the process of programming in Python.
Programming involves a lot of design decisions,
but the process of scripting in Python
is more like writing the specific words
that the actors will say.
In Python, it's good practice to start with a comment.
A comment is a note programmers make
about the intention behind their code.
Let's add one now.
We start with the hash symbol
to indicate that this is a comment,
and then we'll add details about our intention.
Here, we're going to print hello Python to the screen.
Okay, now let's write our first line of Python code.
This code uses print.
Print outputs a specified object to the screen.
After print, we put what we want to output in parentheses.
In this case, we want to output the string hello Python.
We must place a string data in quotation marks.
These quotation marks are just one example of syntax
that you will encounter in Python.
Syntax refers to the rules that determine
what is correctly structured in a computing language.
And now, we'll run this code
so the computer can output the string.
You just run your first line of code.
Since our syntax is correct, the string is now displayed.
Now that you've experienced writing
and running code in Python,
we're ready to discuss its basic components.
Meet you soon.
