# module 4 (36% of the course lmfao)

# Welcome to module 4

We've learned a lot about Python together already, and we still have more to cover.  
In this section, we're going to explore how a security analyst like yourself puts Python into practice.  
As a security analyst, you will likely work with security logs that capture information on various system activities.  
These logs are often very large and hard to quickly interpret.  
But Python can easily automate these tasks and make things much more efficient.  
So first, we'll focus on opening and reading files in Python.  
This includes log files.  
We'll then explore parsing files.  
This means you'll be able to work with files in ways that provide you with the security-related information that you're targeting.  
Finally, part of writing code is debugging code.  
It's important to be able to interpret error messages to make your code work.  
We'll cover common types of Python errors and ways to resolve them.  
Overall, after completing this section, you'll have a better understanding of Python and how as a security analyst you can use it.  
I can't wait to join you.

# Automate cybersecurity tasks with Python

Automation is a key concern in the security profession.  
For example, it would be difficult to monitor each individual attempt to access the system.  
For this reason, it's helpful to automate the security controls put in place to keep malicious actors out of the system.  
And it's also helpful to automate the detection of unusual activity.  
Python is great for automation.  
Let's explore three specific examples of this.  
First, imagine you're a security analyst for a health care company that stores confidential patient records in a database server.  
Your company wants to implement additional controls to protect this information.  
In order to enhance the security of the records, you decide to implement a timeout policy that locks out a user if they spent more than three minutes logging into the database.  
This is because it's possible that if a user is spending too much time, it could be that they are guessing the password.  
To do this, you can use Python to identify when a user has entered a username and start tracking the time until this user enters the correct password.  
Now, let's cover a different example.  
This time, imagine you are a security analyst working at a law firm.  
There have recently been some ongoing security attacks where threat actors hack into employee accounts and attempt to steal client information.  
They then threaten to use this maliciously.  
So the security team is working to target all security vulnerabilities that allow these attackers to break into the company's databases.  
You personally are responsible for tracking all user logins by checking their login timestamp, IP address, and location of login.  
For example, if a user logs in during the early hours of the morning, they should be flagged.  
Also, if they are logging in from a location that's not one of the two established work zones, you must flag their account.  
Finally, if a user is simultaneously logged in from two different IP addresses, you must flag their account.  
Python can help you keep track of and analyze all of this different login information.  
Let's consider one final example.  
Imagine you are a security analyst working at a large organization.  
Recently, this organization has increased security measures to make sure all customer-facing applications are better protected.  
Since there is a password to access these applications, they want to monitor all password login attempts for suspicious activity.  
One sign of suspicious activity is having several failed login attempts within a short amount of time.  
You need to flag users if they had more than three login failures in the last 30 minutes.  
One way you could do this in Python is by parsing a static txt log file with all user login attempts to each machine.  
Python could structure the information in this file, including the username, IP address, timestamp, and login status.  
It could then use conditionals to determine if a user needs to be flagged.  
These are just a few examples of how a security analyst might apply Python in their day-to-day work.  
I hope you are as excited as I am to create solutions for security problems.

# Essential Python components for automation

Throughout this course, you explored coding in Python. You've focused on variables, conditional statements, iterative statements, functions, and a variety of ways to work with strings and lists. In this reading, you will explore why these are all essential components when automating tasks through Python, and you'll be introduced to another necessary component: working with files.

## Automating tasks in Python

**Automation** is the use of technology to reduce human and manual effort to perform common and repetitive tasks. As a security analyst, you will primarily use Python to automate tasks.

You have encountered multiple examples of how to use Python for automation in this course, including investigating logins, managing access, and updating devices.

Automating cybersecurity-related tasks requires understanding the following Python components that you've worked with in this course:

### Variables

A **variable** is a container that stores data. Variables are essential for automation. Without them, you would have to individually rewrite values for each action you took in Python.

### Conditional statements

A **conditional statement** is a statement that evaluates code to determine if it meets a specified set of conditions. Conditional statements allow you to check for conditions before performing actions. This is much more efficient than manually evaluating whether to apply an action to each separate piece of data.

### Iterative statements

An **iterative statement** is code that repeatedly executes a set of instructions. You explored two kinds of iterative statements: <var>for</var> loops and <var>while</var> loops. In both cases, they allow you to perform the same actions a certain number of times without the need to retype the same code each time. Using a <var>for</var> loop allows you to automate repetition of that code based on a sequence, and using a <var>while</var> loop allows you to automate the repetition based on a condition.

### Functions

A **function** is a section of code that can be reused in a program. Functions help you automate your tasks by reducing the need to incorporate the same code multiple places in a program. Instead, you can define the function once and call it wherever you need it.

You can develop your own functions based on your particular needs. You can also incorporate the built-in functions that exist directly in Python without needing to manually code them.

### Techniques for working with strings

String data is one of the most common data types that you'll encounter when automating cybersecurity tasks through Python, and there are a lot of techniques that make working with strings efficient. You can use bracket notation to access characters in a string through their indices. You can also use a variety of functions and methods when working with strings, including <var>str()</var>, <var>len()</var>, and <var>.index()</var>.

### Techniques for working with lists

List data is another common data type. Like with strings, you can use bracket notation to access a list element through its index. Several methods also help you with automation when working with lists. These include <var>.insert()</var>, <var>.remove()</var>, <var>.append()</var>, and <var>.index()</var>.

### Example: Counting logins made by a flagged user

As one example, you may find that you need to investigate the logins of a specific user who has been flagged for unusual activity. Specifically, you are responsible for counting how many times this user has logged in for the day. If you are given a list identifying the username associated with each login attempt made that day, you can automate this investigation in Python.

To automate the investigation, you'll need to incorporate the following Python components:

<div class="rc-CML" dir="auto" id="bkmrk-a-for-loop-will-allo"><div><div data-track="true" data-track-action="click" data-track-app="open_course_home" data-track-component="cml" data-track-page="reading_item" role="presentation"><div data-track="true" data-track-action="click" data-track-app="open_course_home" data-track-component="cml_link" data-track-page="reading_item"><div class="css-1kgqbsw" data-testid="cml-viewer">- A <var>for</var> loop will allow you to iterate through all the usernames in the list.
- Within the <var>for</var> loop, you should incorporate a conditional statement to examine whether each username in the list matches the username of the flagged user.
- When the condition evaluates to <var>True</var>, you also need to increment a counter variable that keeps track of the number of times the flagged user appears in the list.

</div></div></div></div></div>Additionally, if you want to reuse this code multiple times, you can incorporate it into a function. The function can include parameters that accept the username of the flagged user and the list to iterate through. (The list would contain the usernames associated with all login attempts made that day.) The function can use the counter variable to return the number of logins for that flagged user.

## Working with files in Python

One additional component of automating cybersecurity-related tasks in Python is understanding how to work with files. Security-related data will often be initially found in log files. A **log** is a record of events that occur within an organization's systems. In logs, lines are often appended to the record as time progresses.

Two common file formats for security logs are <var>.txt</var> files and <var>.csv</var> files. Both <var>.txt</var> and <var>.csv</var> files are types of text files, meaning they contain only plain text. They do not contain images and do not specify graphical properties of the text, including font, color, or spacing. In a <var>.csv</var> file, or a "comma-separated values" file, the values are separated by commas. In a <var>.txt</var> file, there is not a specific format for separating values, and they may be separated in a variety of ways, including spaces.

You can easily extract data from <var>.txt</var> and <var>.csv</var> files. You can also convert both into other file formats.

Coming up, you'll learn how to import, read from, and write to files. You will also explore how to structure the information contained in files.

## Key takeaways

It is important for security analysts to be able to automate tasks in Python. This requires knowledge of fundamental Python concepts, including variables, conditional statements, iterative statements, and techniques for working with strings and lists. In addition, the ability to work with files is also essential for automation in Python.

# Clancy: Continual learning and Python

My name is Clancy and I'm a Senior Security Engineer.  
My team here at Google is part of an ongoing effort to protect Google's sensitive information, customer data, PII.  
Everyday is different at my job, it allows me to use different skills, knowledge sets, and no day is alike.  
By trade, I am not a engineer or software engineer at all.  
I was actually in accounting.  
Being affected by any type of cybersecurity attack definitely gives you a perspective on the opposite side.  
You get to see how this affects users, how this affects people that were attacked.  
Had I known when I first started out how big of a field cybersecurity really was, it would have allowed me to explore.  
Python is a developmental language.  
I use it very frequently at my role at Google.  
One of my favorite things about Python is the power of the language.  
You can use it to create very powerful scripts that you'll use in your day-to-day role.  
When I first picked up Python, the trickiest part was learning how to say things the Pythonic way.  
I used various resources online as well as books, as well as picking up side projects.  
One of the best things about Python it's a very widely used language and you can find many resources online depending on your skill set.  
Python, as well as any other developmental language, is constantly evolving.  
Continue to take on projects, continue to stretch your knowledge and you'll continue to grow.  
The advice I can give for a person starting to learn Python is make it fun.  
I think once you find a learning a language to be fun, it allows you to be more engaged.  
Develop a good baseline for what cybersecurity is.  
Make yourself a little well-rounded in the beginning and then from there you can branch out and deep dive into subjects that are interesting to you.  
When starting out, it can be very tough and you feel as if you're climbing up a big hill.  
Persevere, continue to learn and it will be a very rewarding experience.

# Access a text file in Python

Security professionals are often tasked with reviewing log files.  
These files may have thousands of entries, so it can be helpful to automate this process, and that's where Python comes in.  
Let's start by importing a simple text file that just contains a few words and then restoring it as a string in Python.  
All we need is the text file, its location, and the right Python keywords.  
We're going to start by typing a "with" statement.  
The keyword with handles errors and manages external resources.  
When using with, Python knows to automatically release resources that would otherwise keep our system busy until the program finishes running.  
It's often used in file handling to automatically close a file after reading it.  
To open files and then read them, we write a statement that begins with the keyword with.  
Then, we use the open() function.  
Open() is a function that opens a file in Python.  
The first parameter is the name of the text file on your computer or a link to it on the internet.  
Depending on the Python environment, you might also need to include a path to this file.  
Remember to include thetxt extension in the file name.  
Now let's discuss the second parameter.  
This parameter in the open() function tells Python what we want to do with the file.  
In our case, we want to read a file, so we use the letter "r" between quotation marks.  
If we wanted to write to a file, we would replace this "r" with a "w".  
But here, we're focusing on reading.  
Finally, file is a variable that contains the file information as long as we're inside the with statement.  
Like with other types of statements, we end our with statement with a colon.  
The code that comes after the colon will tell Python what to do with the content of the file.  
Let's go into Python and use what we learned.  
We're ready to open a text file in Python.  
Now we'll type our with statement.  
Next, we'll use Python's built-in read method.  
The read method converts files into strings.  
Now let's go back to our with statement.  
Similar to a for loop, with statements start an indent on the next line.  
This tells Python that this code is happening inside the with statement.  
Inside of the statement, we're going to use the read() function to turn our file into a string and store that inside a new variable.  
This new variable can be used outside of the with statement.  
So let's exit the with statement by removing the indentation and print the variable.  
Perfect!  
The string from the text prints out.  
Coming up, we're going to discuss parsing files so we are equipped to handle security logs in the future.

# Import files into Python

Previously, you explored how to open files in Python, convert them into strings, and read them. In this reading, you'll review the syntax needed for this. You'll also focus on why the ability to work with files is important for security analysts using Python, and you will learn about writing files.

## Working with files in cybersecurity 

Security analysts may need to access a variety of files when working in Python. Many of these files will be logs. A **log** is a record of events that occur within an organization's systems.

For instance, there may be a log containing information on login attempts. This might be used to identify unusual activity that signals attempts made by a malicious actor to access the system.

As another example, malicious actors that have breached the system might be capable of attacking software applications. An analyst might need to access a log that contains information on software applications that are experiencing issues.

## Opening files in Python

To open a file called <var>"update\_log.txt"</var> in Python for purposes of reading it, you can incorporate the following line of code:

<var>with open("update\_log.txt", "r") as file:</var>

This line consists of the <var>with</var> keyword, the <var>open()</var> function with its two parameters, and the <var>as</var> keyword followed by a variable name. You must place a colon (<var>:</var>) at the end of the line.

### with

The keyword <var>with</var> handles errors and manages external resources when used with other functions. In this case, it's used with the <var>open()</var> function in order to open a file. It will then manage the resources by closing the file after exiting the <var>with</var> statement.

**Note:** You can also use the <var>open()</var> function without the <var>with</var> keyword. However, you should close the file you opened to ensure proper handling of the file.

### open()

The <var>open()</var> function opens a file in Python.

The first parameter identifies the file you want to open. In the following file structure, <var>"update\_log.txt"</var> is located in the same directory as the Python file that will access it, <var>"log\_parser.ipynb"</var>:

[![root file system example chart.png](https://library.naruzkurai.com/uploads/images/gallery/2023-12/scaled-1680-/root-file-system-example-chart.png)](https://library.naruzkurai.com/uploads/images/gallery/2023-12/root-file-system-example-chart.png)

Because they're in the same directory, only the name of the file is required. The code can be written as <var>with open("update\_log.txt", "r") as file:</var>.

However, <var>"access\_log.txt"</var> is not in the same directory as the Python file <var>"log\_parser.ipynb"</var>. Therefore, it's necessary to specify its absolute file path. A **file path** is the location of a file or directory. An absolute file path starts from the highest-level directory, the root. In the following code, the first parameter of the <var>open()</var> function includes the absolute file path to <var>"access\_log.txt"</var>:

<var>with open("/home/analyst/logs/access\_log.txt", "r") as file:</var>

**Note:** In Python, the names of files or their file paths can be handled as string data, and like all string data, you must place them in quotation marks.

The second parameter of the <var>open()</var> function indicates what you want to do with the file. In both of these examples, the second parameter is <var>"r"</var>, which indicates that you want to read the file. Alternatively, you can use <var>"w"</var> if you want to write to a file or <var>"a"</var> if you want to append to a file.

### as

When you open a file using <var>with open()</var>, you must provide a variable that can store the file while you are within the <var>with</var> statement. You can do this through the keyword <var>as</var> followed by this variable name. The keyword <var>as</var> assigns a variable that references another object. The code <var>with open("update\_log.txt", "r") as file:</var> assigns <var>file</var> to reference the output of the <var>open()</var> function within the indented code block that follows it.

## Reading files in Python

After you use the code <var>with open("update\_log.txt", "r") as file:</var> to import <var>"update\_log.txt"</var> into the <var>file</var> variable, you should indicate what to do with the file on the indented lines that follow it. For example, this code uses the <var>.read()</var> method to read the contents of the file:

<var>with open("update\_log.txt", "r") as file:</var>

<var> updates = file.read()</var>

<var>print(updates)</var>

The <var>.read()</var> method converts files into strings. This is necessary in order to use and display the contents of the file that was read.

In this example, the <var>file</var> variable is used to generate a string of the file contents through <var>.read()</var>. This string is then stored in another variable called <var>updates</var>. After this, <var>print(updates)</var> displays the string.

Once the file is read into the <var>updates</var> string, you can perform the same operations on it that you might perform with any other string. For example, you could use the <var>.index()</var> method to return the index where a certain character or substring appears. Or, you could use <var>len()</var> to return the length of this string.

## Writing files in Python

Security analysts may also need to write to files. This could happen for a variety of reasons. For example, they might need to create a file containing the approved usernames on a new allow list. Or, they might need to edit existing files to add data or to adhere to policies for standardization.

To write to a file, you will need to open the file with <var>"w"</var> or <var>"a"</var> as the second argument of <var>open()</var>.

You should use the <var>"w"</var> argument when you want to replace the contents of an existing file. When working with the existing file <var>update\_log.txt</var>, the code <var>with open("update\_log.txt", "w") as file:</var> opens it so that its contents can be replaced.

Additionally, you can use the <var>"w"</var> argument to create a new file. For example, <var>with open("update\_log2.txt", "w") as file:</var> creates and opens a new file called <var>"update\_log2.txt"</var>.

You should use the <var>"a"</var> argument if you want to append new information to the end of an existing file rather than writing over it. The code <var>with open("update\_log.txt", "a") as file:</var> opens <var>"update\_log.txt"</var> so that new information can be appended to the end. Its existing information will not be deleted.

Like when opening a file to read from it, you should indicate what to do with the file on the indented lines that follow when you open a file to write to it. With both <var>"w"</var> and <var>"a"</var>, you can use the <var>.write()</var> method. The <var>.write()</var> method writes string data to a specified file.

The following example uses the <var>.write()</var> method to append the content of the <var>line</var> variable to the file <var>"access\_log.txt"</var>.

<var>line = "jrafael,192.168.243.140,4:56:27,True"</var>

<var>with open("access\_log.txt", "a") as file:</var>

<var> file.write(line)</var>

**Note:** Calling the <var>.write()</var> method without using the <var>with</var> keyword when importing the file might result in its arguments not being completely written to the file if the file is not properly closed in another way.

## Key takeaways

It's important for security analysts to be able to import files into Python and then read from or write to them. Importing Python files involves using the <var>with</var> keyword, the <var>open()</var> function, and the <var>as</var> keyword. Reading from and writing to files requires knowledge of the <var>.read()</var> and <var>.write()</var> methods and the arguments to the <var>open()</var> function of <var>"r"</var>, <var>"w"</var>, and <var>"a"</var>.

# Parse a text file in Python

Now that you know how to import text files into Python, we're going to take this one step further and learn how to give them a structure.  
This will allow us to analyze them more easily.  
This process is often referred to as parsing.  
Parsing is the process of converting data into a more readable format.  
To do this, we're going to put together everything we learned about lists and strings and learn another method for working with strings in Python.  
The method we need is the split method.  
The split method converts a string into a list.  
It does this by separating the string based on a specified character.  
Or, if no argument is passed, every time it encounters a whitespace, it separates the string.  
So, a split would convert the string "We are learning about parsing!" into this list.  
We are using the split method to separate the strings into smaller chunks that we can analyze more easily than one big block of text.  
In this video, we'll work with an example of a security log where every line represents a new data point.  
To store these points in a list, we want to separate the text based on the new line.  
Python considers a new line to be a type of whitespace.  
We can use the split method without passing an argument.  
We'll start with our code from the previous video.  
Remember, we used this code to open a file and then read it into a string.  
Now, let's split that string into a list using the split method and then print the output.  
After we run it, Python outputs a list of usernames instead of one big string of them.  
If we want to save this list, we would need to assign it to another variable.  
For example, we can call the variable usernames.  
And then we'll run it again.  
And now this list can be reused in other code.  
Congratulations!  
You just learned the basics of parsing a text file in Python.  
In the next videos, we're going to be exploring techniques that help us work more in depth with data in Python.  
Now that you know how to import text files into Python,.  
​

# Work with files in Python

You previously explored how to open files in Python as well as how to read them and write to them. You also examined how to adjust the structure of file contents through the <var>.split()</var> method. In this reading, you'll review the <var>.split()</var> method, and you'll also learn an additional method that can help you work with file contents.

## Parsing

Part of working with files involves structuring its contents to meet your needs. **Parsing** is the process of converting data into a more readable format. Data may need to become more readable in a couple of different ways. First, certain parts of your Python code may require modification into a specific format. By converting data into this format, you enable Python to process it in a specific way. Second, programmers need to read and interpret the results of their code, and parsing can also make the data more readable for them.

Methods that can help you parse your data include <var>.split()</var> and <var>.join()</var>.

## .split()

### **The basics of .split()**

The <var>.split()</var> method converts a string into a list. It separates the string based on a specified character that's passed into <var>.split()</var> as an argument.

In the following example, the usernames in the <var>approved\_users</var> string are separated by a comma. For this reason, a string containing the comma (<var>","</var>) is passed into <var>.split()</var> in order to parse it into a list. Run this code and analyze the different contents of <var>approved\_users</var> before and after the <var>.split()</var> method is applied to it:

```python
approved_users = "elarson,bmoreno,tshah,sgilmore,eraab"
print("before .split():", approved_users)
approved_users = approved_users.split(",")
print("after .split():", approved_users)
```

```
before .split(): elarson,bmoreno,tshah,sgilmore,eraab
after .split(): ['elarson', 'bmoreno', 'tshah', 'sgilmore', 'eraab']
```

Before the <var>.split()</var> method is applied to <var>approved\_users</var>, it contains a string, but after it is applied, this string is converted to a list.

If you do not pass an argument into <var>.split()</var>, it will separate the string every time it encounters a whitespace.

**Note:** A variety of characters are considered whitespaces by Python. These characters include spaces between characters, returns for new lines, and others.

The following example demonstrates how a string of usernames that are separated by space can be split into a list through the <var>.split()</var> method:

```python
removed_users = "wjaffrey jsoto abernard jhill awilliam"
print("before .split():", removed_users)
removed_users = removed_users.split()
print("after .split():", removed_users)
```

```
before .split(): wjaffrey jsoto abernard jhill awilliam
after .split(): ['wjaffrey', 'jsoto', 'abernard', 'jhill', 'awilliam']
```

Because an argument isn't passed into <var>.split()</var>, Python splits the <var>removed\_users</var> string at each space when separating it into a list.

### **Applying .split() to files**

The <var>.split()</var> method allows you to work with file content as a list after you've converted it to a string through the <var>.read()</var> method. This is useful in a variety of ways. For example, if you want to iterate through the file contents in a <var>for</var> loop, this can be easily done when it's converted into a list.

The following code opens the <var>"update\_log.txt"</var> file. It then reads all of the file contents into the <var>updates</var> variable as a string and splits the string in the <var>updates</var> variable into a list by creating a new element at each whitespace:

```python
with open("update_log.txt", "r") as file:
    updates = file.read()
updates = updates.split()
```

After this, through the <var>updates</var> variable, you can work with the contents of the <var>"update\_log.txt"</var> file in parts of your code that require it to be structured as a list.

**Note:** Because the line that contains <var>.split()</var> is not indented as part of the <var>with</var> statement, the file closes first. Closing a file as soon as it is no longer needed helps maintain code readability. Once a file is read into the <var>updates</var> variable, it is not needed and can be closed.

## .join()

### **The basics of .join()**

If you need to convert a list into a string, there is also a method for that. The <var>.join()</var> method concatenates the elements of an iterable into a string. The syntax used with <var>.join()</var> is distinct from the syntax used with <var>.split()</var> and other methods that you've worked with, such as <var>.index()</var>.

In methods like <var>.split()</var> or <var>.index()</var>, you append the method to the string or list that you're working with and then pass in other arguments. For example, the code <var>usernames.index(2)</var>, appends the <var>.index()</var> method to the variable <var>usernames</var>, which contains a list. It passes in <var>2</var> as the argument to indicate which element to return.

However, with <var>.join()</var>, you must pass the list that you want to concatenate into a string in as an argument. You append <var>.join()</var> to a character that you want to separate each element with once they are joined into a string.

For example, in the following code, the <var>approved\_users</var> variable contains a list. If you want to join that list into a string and separate each element with a comma, you can use <var>",".join(approved\_users)</var>. Run the code and examine what it returns:

```python
approved_users = ["elarson", "bmoreno", "tshah", "sgilmore", "eraab"]
print("before .join():", approved_users)
approved_users = ",".join(approved_users)
print("after .join():", approved_users)
```

```
before .join(): ['elarson', 'bmoreno', 'tshah', 'sgilmore', 'eraab']
after .join(): elarson,bmoreno,tshah,sgilmore,eraab
```

Before <var>.join()</var> is applied, <var>approved\_users</var> is a list of five elements. After it is applied, it is a string with each username separated by a comma.

**Note**: Another way to separate elements when using the <var>.join()</var> method is to use <var>"\\n"</var>, which is the newline character. The <var>"\\n"</var> character indicates to separate the elements by placing them on new lines.

### **Applying .join() to files**

When working with files, it may also be necessary to convert its contents back into a string. For example, you may want to use the <var>.write()</var> method. The <var>.write()</var> method writes string data to a file. This means that if you have converted a file's contents into a list while working with it, you'll need to convert it back into a string before using <var>.write()</var>. You can use the <var>.join()</var> method for this.

You already examined how <var>.split()</var> could be applied to the contents of the <var>"update\_log.txt"</var> file once it is converted into a string through <var>.read()</var> and stored as <var>updates</var>:

```python
with open("update_log.txt", "r") as file:
    updates = file.read()
updates = updates.split()
```

After you're through performing operations using the list in the <var>updates</var> variable, you might want to replace <var>"update\_log.txt"</var> with the new contents. To do so, you need to first convert updates back into a string using <var>.join()</var>. Then, you can open the file using a <var>with</var> statement and use the <var>.write()</var> method to write the <var>updates</var> string to the file:

```python
updates = " ".join(updates)
with open("update_log.txt", "w") as file:
    file.write(updates)
```

The code <var>" ".join(updates)</var> indicates to separate each of the list elements in <var>updates</var> with a space once joined back into a string. And because <var>"w"</var> is specified as the second argument of <var>open()</var>, Python will overwrite the contents of <var>"update\_log.txt"</var> with the string currently in the <var>updates</var> variable.

## Key takeaways

An important element of working with files is being able to parse the data it contains. Parsing means converting the data into a readable format. The <var>.split()</var> and <var>.join()</var> methods are both useful for parsing data. The <var>.split()</var> method allows you to convert a string into a list, and the <var>.join()</var> method allows you to convert a list into a string.

# Develop a parsing algorithm in Python

We're now going to bring all of the pieces together to import a file, parse it, and implement a simple algorithm to help us detect suspicious login attempts.  
In this video, we want to create a program that runs every time a new user logs in and checks if that user has had three or more failed login attempts.  
First, let's discuss the structure of our inputs to build a strategy to develop our program.  
We have a log file stored in atxt format that contains one username per line.  
Each username represents a failed login attempt.  
So when a user logs in, we want our program to check for their username and count how many times that username is in our log file.  
If that username is repeated three or more times, the program returns an alert.  
We'll start with code that imports the file of logging attempts, splits it, and stores it into a variable named usernames.  
Let's try printing the variable user names to check for its contents.  
We'll run this.  
Perfect!  
This is exactly what we expected.  
The variable usernames is ready to be used in our algorithm.  
Now let's develop a strategy for counting username occurrences in the list.  
We'll start with the first eight elements of the usernames list.  
We notice that there are two occurrences of the username "eraab" in the list, but how would we tell Python to count this?  
We'll implement a for loop that iterates through every element.  
Let's represent the loop variable with an arrow.  
We'll also define a counter variable that starts at 0.  
So, our for loop starts at the username "elarson." At every element, Python asks, "Is this element equal to the string 'eraab'?" If the answer is yes, the counter goes up by one.  
If it isn't, then the counter stays the same.  
Since "elarson" is not the same as "eraab," the counter remains 0.  
Then, we move on to the next element.  
We encounter our first occurrence of "eraab." At this point, the counter increases by 1.  
As we move to the next element, we find another occurrence of "eraab," so we increase our counter by 1 again.  
That means that our counter is now at 2.  
We will continue this process for the rest of the list.  
Now that we know the solution, let's talk about how to implement it in Python.  
Solving the problem in Python will involve a for loop, a counter variable, and an if statement.  
Let's get back into our code.  
We'll create a function that counts a user's failed login attempts.  
First, let's define our function.  
We'll call it login\_check().  
It takes two parameters.  
The first is called login\_list.  
This will be used for the list of failed login attempts.  
The second is called current\_user.  
This will be used for the user who logs in.  
Inside of this function, we start by defining the counter variable and set its value to 0.  
Now we start the for loop.  
We'll use i as our loop variable and iterate through the login list.  
In other words, as the loop iterates, it will run through all the failed login attempts in the list.  
Directly inside of the for loop, we start the if statement.  
The if statement checks if our loop variable is equal to the current\_user we're searching for.  
If this condition is true, We want to add 1 to the counter.  
We're almost done with our algorithm.  
Now, we just need the final if-else statement to print the alert.  
If the counter adds up to 3 or more, we need to tell the user that their account is locked so they can't log in.  
We'll also type an else statement for users who can log in.  
Our algorithm is complete!  
Let's try out our new function on an example username.  
We can pull out a few of the usernames in the list and try our function on them.  
Let's use the first name in the list.  
Let's run the code.  
According to our code, this user can log in.  
They have fewer than three failed login attempts.  
Now let's go back to our user "eraab." Remember, they had two entries in the list of the first eight names in our failed login attempts.  
Do you think they'll be able to log in?  
When we run, we get an "account locked" message.  
This means they had three or more failed login attempts.  
Excellent work!  
You've just developed your first security algorithm involving a log.  
As you grow in your skills, you'll learn how to make this algorithm more efficient, but this solution works well for now.  
In this video, we recapped everything we learned so far, from list operations to algorithm development, all the way to file parsing.  
We did this while building an algorithm we can apply in a security context.

# Portfoleo project: Algorythm for file updates in Python

# <span style="font-size: 20pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Algorithm for file updates in Python</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Project description</span>

<span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">this script automates management of an ip allowlist. the allowlist is in a file, and the script reads and writes to file.</span></span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Open the file that contains the allow list</span>

```python
import_file = "allow_list.txt"

# Assign `remove_list` to a list of IP addresses that are no longer allowed to access restricted information. 

remove_list = ["192.168.97.225", "192.168.158.170", "192.168.201.40", "192.168.58.57"]

# First line of `with` statement to open the file and store as variable file

with open(import_file, "r") as file:
```

<span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">  
</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Read the file contents</span>

```python
with open(import_file, "r") as file:

  # Use `.read()` to read the imported file and store it in a variable named `ip_addresses`

  ip_addr = file.read()
```

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Convert the string into a list</span>

```python
with open(import_file, "r") as file:

  # Use `.read()` to read the imported file and store it in a variable named `ip_addresses`

  ip_addresses = file.read()

# Use `.split()` to convert `ip_addresses` from a string to a list

ip_addresses = ip_addresses.split("\n")

# Display `ip_addresses`

print(ip_addresses)
```

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Iterate through the remove list</span>

```python
for element in ip_addresses:

    # Display `element` in every iteration

    print(element)
```

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Remove IP addresses that are on the remove list</span>

```python
for element in ip_addresses:
  
  # Build conditional statement
  # If current element is in `remove_list`,
  
    if element in remove_list:

        # then current element should be removed from `ip_addresses`

        ip_addresses.remove(element)
        # add to ips renmoved list

# Display `ip_addresses` 

print(ip_addresses)
```

<span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">  
</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Update the file with the revised list of IP addresses </span>

```python
# Assign `import_file` to the name of the file 

import_file = "allow_list.txt"

# Assign `remove_list` to a list of IP addresses that are no longer allowed to access restricted information. 

remove_list = ["192.168.97.225", "192.168.158.170", "192.168.201.40", "192.168.58.57"]

# Build `with` statement to read in the initial contents of the file

with open(import_file, "r") as file:

  # Use `.read()` to read the imported file and store it in a variable named `ip_addresses`

  ip_addresses = file.read()

# Use `.split()` to convert `ip_addresses` from a string to a list

ip_addresses = ip_addresses.split()

# Build iterative statement
# Name loop variable `element`
# Loop through `ip_addresses`

for element in ip_addresses:
  
  # Build conditional statement
  # If current element is in `remove_list`,
  
    if element in remove_list:

        # then current element should be removed from `ip_addresses`

        ip_addresses.remove(element)

# Convert `ip_addresses` back to a string so that it can be written into the text file 

ip_addresses = " ".join(ip_addresses)    

# Build `with` statement to rewrite the original file

with  open(import_file, "w") as file:

  # Rewrite the file, replacing its contents with `ip_addresses`

    file.write(ip_addresses)
```

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Final</span>

create the allow-list as a file

```python
# Assign `import_file` to the name of the file 

import_file = "allow_list.txt"
allow_list = """ip_address
192.168.25.60
192.168.205.12
192.168.97.225
192.168.6.9
192.168.52.90
192.168.158.170
192.168.90.124
192.168.186.176
192.168.133.188
192.168.203.198
192.168.201.40
192.168.218.219
192.168.52.37
192.168.156.224
192.168.60.153
192.168.58.57
192.168.69.116"""
# Assign `remove_list` to a list of IP addresses that are no longer allowed to access restricted information. 

remove_list = ["192.168.97.225", "192.168.158.170", "192.168.201.40", "192.168.58.57"]

# Build `with` statement to read in the initial contents of the file

with open(import_file, "r") as file:

  # Use `.read()` to read the imported file and store it in a variable named `ip_addresses`

  ip_addr = file.read()
    
temp_file = "task_3_remove_list.txt"
import_file = temp_file

with open(import_file, "w") as import_file:
    import_file.write(ip_addr)



# Display `ip_addresses`

print(ip_addr)
```

<span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">  
</span>

modify and prune the allow-list

```python
# Assign `import_file` to the name of the file 

import_file = "allow_list.txt"

# Assign `remove_list` to a list of IP addresses that are no longer allowed to access restricted information. 

remove_list = ["192.168.97.225", "192.168.158.170", "192.168.201.40", "192.168.58.57"]

# Build `with` statement to read in the initial contents of the file

with open(import_file, "r") as file:

  # Use `.read()` to read the imported file and store it in a variable named `ip_addresses`

  ip_addresses = file.read()

# Use `.split()` to convert `ip_addresses` from a string to a list

ip_addresses = ip_addresses.split()

# Build iterative statement
# Name loop variable `element`
# Loop through `ip_addresses`

for element in ip_addresses:
  
  # Build conditional statement
  # If current element is in `remove_list`,
  
    if element in remove_list:

        # then current element should be removed from `ip_addresses`

        ip_addresses.remove(element)

# Convert `ip_addresses` back to a string so that it can be written into the text file 

ip_addresses = " ".join(ip_addresses)       

# Build `with` statement to rewrite the original file

with open(import_file, "w") as file:

  # Rewrite the file, replacing its contents with `ip_addresses`

  file.write(ip_addresses)

# Build `with` statement to read in the updated file

with open(import_file, "r") as file:

    # Read in the updated file and store the contents in `text`

    text = file.read()

# Display the contents of `text`

print(text)
```

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Summary</span>

<span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">in a hypothetical scenario where you needed to remove information from a large file this could save alot of time. this can save you lots of time.</span>

# Debugging strategies

As a security analyst, you might be required to read or write code.  
One of the biggest challenges is getting it to run and function properly.  
In fact, fixing complex errors in code can sometimes take up just as much, if not more, time than writing your code.  
This is why it's important to develop this skill.  
Now that you've learned the basics of coding in Python, it's important to learn how to deal with errors.  
For that reason, we'll focus on debugging your code.  
Debugging is the practice of identifying and fixing errors in code.  
In this video, we'll explore some techniques for this.  
There are three types of errors: syntax errors, logic errors, and exceptions.  
Syntax errors involve invalid usage of the Python language, such as forgetting to add a colon after a function header.  
Let's explore this type of error.  
When we run this code, we get a message that indicates there's a syntax error.  
Depending on the Python environment, it may also display additional details.  
We'll typically get information about the error, like its location.  
These syntax errors are often easy to fix since you can find exactly where the error happened.  
They are similar to correcting simple grammar mistakes in an email.  
Since their message tells us the problem is on the line that defines the function, let's go there.  
In this case, we can add a colon to the header and resolve our error.  
When we run it again, there's no longer an error message.  
This is just one example of a syntax error.  
Other examples include omitting a parenthesis after a function, misspelling a Python keyword, or not properly closing quotation marks for a string.  
Next, let's focus on logic errors.  
Logic errors may not cause error messages; instead, they produce unintended results.  
A logic error could be as simple as writing the incorrect text within a print statement, or it might involve something like writing a less than symbol instead of less than or equal to symbol.  
This change in operator would exclude a value that was needed for the code to work as intended.  
For example, imagine that you reach out to a response team when the priority level of an issue is less than three instead of less than or equal to three.  
This means all events classified as priority level 3 could go unnoticed and unresolved.  
To diagnose a logic error that's difficult to find, one strategy is to use print statements.  
You'll need to insert print statements throughout your code.  
The print statements should describe the location in the code; for example, "print line 20" or "print line 55: inside the conditional".  
The idea is to use these print statements to identify which sections of the code are functioning properly.  
When a print statement doesn't print as expected, this helps you identify sections of the code with problems.  
Another option for identifying logic errors is to use a debugger.  
A debugger will let you insert breakpoints into your code.  
Breakpoints allow you to segment your code into sections and run just one portion at a time.  
Just like with the print statements, running these sections independently can help isolate problems in the code.  
Let's move on to our last type of error: an exception.  
Exceptions happen when the program doesn't know how to execute code even though there are no problems with the syntax.  
Exceptions occur for a variety of reasons.  
For example, they can happen when something is mathematically impossible, like asking the code to divide something by 0.  
Exceptions might also happen when you ask Python to access index values that don't exist or when Python doesn't recognize variable or function names.  
Exceptions also may occur when you use an incorrect data type.  
Let's demonstrate an exception.  
Let's say you have a variable called my\_string that contains the word "security".  
Since this string has 8 characters, we can successfully print any index less than 8.  
Index 0 contains "s." Index 1 contains "e." And index 2 contains "c." But, if you try to access the character at index 100, you'll get an error.  
Let's run this and explore what happens.  
After it successfully prints the first three statements, we get an error message: "string index out of range." For exception errors, you can also make use of debuggers and print statements to figure out the potential source of error.  
Errors and exceptions can be expected when working in Python.  
The important thing is to know how to deal with them.  
Hopefully, this video provided some valuable insight about debugging code.  
This will help ensure that the code that you write is functional.

# Matt: Learning from mistakes

My name is Matt.  
I'm a software engineer working in cybersecurity.  
When I was in high school, what I really want to do is music, I was a musician.  
I went to music school for jazz trombone.  
Partway through that process, I realized, no, bandleader in their right mind, looks at a group and thinks, we need a trombone player.  
This is what makes us better.  
I grew up watching movies like The Matrix, and it's not very realistic to what cybersecurity work actually is, but it is inspiring.  
If you dig through the work at specifics of what you do and take the broad step back like you are that cool guy with sunglasses, you're a hacker.  
When I first started writing code, I would look at coding errors as a sign that I have done bad.  
But as I grew older, a little bit more mature, I realized everyone has coding errors.  
Literally the very best software engineer I know writes code and it has errors.  
Errors represent a moment where you can take a step back and say, what did I do wrong?  
It's a learning opportunity.  
Now, I see these like moments where I can look at some problems that I don't understand and be like, why?  
Dive into it and expand my knowledge of computer science, which is my whole job.  
I see this as a learning process and it's a little bit fun.  
One of the really messy coding areas that I've run into in my time here at Google involved fingerprinting when we find a vulnerability.  
If we find the same vulnerability later, we don't want to have two vulnerabilities, we don't want to poke someone twice and be like, fix this thing if it's the exact same thing.  
We do this thing called fingerprinting where we say this vulnerability has a specific fingerprint and if we find another vulnerability that has the same fingerprint, we're not going to store them separately or treat them separately.  
They're effectively the same.  
I was running into these errors where things would not fingerprint in the way that I expected them to.  
I was literally grinding my gears for weeks, trying to figure out what is going on with this thing?  
But when I found it was very satisfying like, that's it.  
When you're in the middle of this mess, all of that self-doubt creeps into your brain.  
You're like, maybe I'm not as good at this thing as I thought I was.  
What I would go back and tell myself: A), it's not endless - it gets better.  
Once you figure it out, that feeling of reward is incredible.  
But B), also, it's okay to rope people in if you are struggling with something, I always advocate for asking for help.  
Most people are really excited to go help you out with this thing, especially when it's a convoluted problem.  
I am so thrilled I ended up in cybersecurity.  
Cybersecurity is having its moment.  
People are realizing, waking up to the amount of data that they're putting out into the world and they're starting to care about it.  
Every day there's something new.  
Every day there's something exciting for me to do and yeah, get into it.  
Cybersecurity is the way.  
​

# Apply debugging strategies

Let's say our co-workers need some help getting their code to work, and we've offered to debug their code to make sure it runs smoothly.  
First, we need to know about the purpose of the code.  
In this case, the purpose of the code is to parse a single line from a log file and return it.  
The log file we're using tracks potential issues with software applications.  
Each line in the log contains the HTTP response status codes, the date, the time, and the application name.  
When writing this code, our co-workers consider whether all these status codes needed to be parsed.  
Since 200 signals a successful event, they concluded that lines with this status code shouldn't be parsed.  
Instead, Python should return a message indicating that parsing wasn't needed.  
To start the debugging process, let's first run the code to identify what errors appear.  
Our first error is a syntax error.  
The error message also tells us the syntax error occurs in a line that defines a function.  
So let's just scroll to that part of the code.  
As you might recall, these function headers should end with a colon.  
Let's go ahead and add that to the code.  
Now, the syntax error should go away.  
Let's run the code again.  
Now our syntax error is gone, which is good news, but we have another error, a "name error." "Name error" is actually a type of exception, meaning we've written valid syntax, but Python can't process the statement.  
According to the error, the interpreter doesn't understand the variable application\_name at the point where it's been added to the parsed\_line list.  
Let's examine that section of code.  
This error means we haven't assigned a variable name properly.  
So now let's go back to where it was first assigned and determine what happened.  
We find that this variable is misspelled.  
There should be two p's in application\_name, not one.  
Let's correct the spelling.  
Now that we've fixed it, it should work.  
So let's run the code.  
Great!  
We fixed an error and an exception.  
And we no longer have any error messages.  
But this doesn't mean our debugging work is done.  
Let's make sure the logic of the program works as intended by examining the output.  
Our output is a parsed line.  
In most cases, this would be what we wanted.  
But as you might recall, if the status code is 200, our code shouldn't parse the line.  
Instead, it should print a message that no parsing is needed.  
And when we called it with a status code of 200, there was a logic error because this message wasn't displayed.  
So let's go back to the conditional we used to handle the status code of 200 and investigate.  
To find the source of the issue, let's add print statements.  
In our print statements, we'll include the line number and the description of the location.  
We'll add one print statement before the line of code containing "return parsed\_list".  
We'll add another above the if statement that checks for the 200 status code to determine if it reaches the if statement.  
We'll add one more print statement inside the if statement to determine whether the program even enters it.  
Now, let's run the code and review what gets printed.  
Only the first print statement printed something.  
The other two print statements after these didn't print.  
This means the program didn't even enter the if statement.  
The problem occurred somewhere before the line that returns the parsed\_line variable.  
Let's investigate.  
When Python encounters the first return statement which sends back the parsed list, it exits the function.  
In other words, it returns the list before it even checks for a status code value of 200.  
To fix this, we must move the if statement, checking for the status code somewhere before "return parsed line".  
Let's first delete our print statements.  
This makes the program more efficient because it doesn't run any unneeded lines of code.  
Now, let's move the if statement.  
We'll place it right after the line of code that involves parsing the status code from the line.  
Let's run our code and confirm that this fixed our issue.  
Yes!  
It printed "Successful event - no parsing needed." Great work!  
We've fixed this logic error.  
I enjoyed debugging this code with you.  
I hope this video has strengthened your understanding of some helpful debugging strategies and gave you an idea of some errors you might encounter.

# Explore debugging techniques

Previously, you examined three types of errors you may encounter while working in Python and explored strategies for debugging these errors. This reading further explores these concepts with additional strategies and examples for debugging Python code.

## Types of errors 

It's a normal part of developing code in Python to get error messages or find that the code you're running isn't working as you intended. The important thing is that you can figure out how to fix errors when they occur. Understanding the three main types of errors can help. These types include syntax errors, logic errors, and exceptions.

### **Syntax errors** 

A **syntax error** is an error that involves invalid usage of a programming language. Syntax errors occur when there is a mistake with the Python syntax itself. Common examples of syntax errors include forgetting a punctuation mark, such as a closing bracket for a list or a colon after a function header.

When you run code with syntax errors, the output will identify the location of the error with the line number and a portion of the affected code. It also describes the error. Syntax errors often begin with the label <var>"SyntaxError:"</var> . Then, this is followed by a description of the error. The description might simply be <var>"invalid syntax"</var> . Or if you forget a closing parentheses on a function, the description might be <var>"unexpected EOF while parsing"</var>. <var>"EOF"</var> stands for "end of file."

The following code contains a syntax error. Run it and examine its output:

```python
message = "You are debugging a syntax error
print(message)
```

```
Error on line 1:
    message = "You are debugging a syntax error
                                              ^
SyntaxError: EOL while scanning string literal
```

This outputs the message <var>"SyntaxError: EOL while scanning string literal"</var>. <var>"EOL"</var> stands for "end of line". The error message also indicates that the error happens on the first line. The error occurred because a quotation mark was missing at the end of the string on the first line. You can fix it by adding that quotation mark.

**Note:** You will sometimes encounter the error label <var>"IndentationError"</var> instead of <var>"SyntaxError"</var>. <var>"IndentationError"</var> is a subclass of <var>"SyntaxError"</var> that occurs when the indentation used with a line of code is not syntactically correct.

### **Logic errors** 

A **logic error** is an error that results when the logic used in code produces unintended results. Logic errors may not produce error messages. In other words, the code will not do what you expect it to do, but it is still valid to the interpreter.

For example, using the wrong logical operator, such as a greater than or equal to sign (<var>&gt;=</var>) instead of greater than sign (<var>&gt;</var>) can result in a logic error. Python will not evaluate a condition as you intended. However, the code is valid, so it will run without an error message.

The following example outputs a message related to whether or not a user has reached a maximum number of five login attempts. The condition in the <var>if</var> statement should be <var>login\_attempts &gt; 5</var>, but it is written as <var>login\_attempts &gt;= 5</var>. A value of <var>5</var> has been assigned to <var>login\_attempts</var> so that you can explore what it outputs in that instance:

```python
login_attempts = 5
if login_attempts >= 5:
    print("User has not reached maximum number of login attempts.")
else:
    print("User has reached maximum number of login attempts.")
```

```
User has not reached maximum number of login attempts.
```

The output displays the message <var>"User has not reached maximum number of login attempts."</var> However, this is not true since the maximum number of login attempts is five. This is a logic error.

Logic errors can also result when you assign the wrong value in a condition or when a mistake with indentation means that a line of code executes in a way that was not planned.

### **Exceptions**

An **exception** is an error that involves code that cannot be executed even though it is syntactically correct. This happens for a variety of reasons.

One common cause of an exception is when the code includes a variable that hasn't been assigned or a function that hasn't been defined. In this case, your output will include <var>"NameError"</var> to indicate that this is a name error. After you run the following code, use the error message to determine which variable was not assigned:

<div id="bkmrk-"></div><div id="bkmrk--1"></div><div id="bkmrk--2"></div>```python
username = "elarson"
month = "March"
total_logins = 75
failed_logins = 18
print("Login report for", username, "in", month)
print("Total logins:", total_logins)
print("Failed logins:", failed_logins)
print("Unusual logins:", unusual_logins)
```

```
Error on line 8:
    print("Unusual logins:", unusual_logins)
NameError: name 'unusual_logins' is not defined
```

The output indicates there is a <var>"NameError"</var> involving the <var>unusual\_logins</var> variable. You can fix this by assigning this variable a value.

In addition to name errors, the following messages are output for other types of exceptions:

- <var>"IndexError"</var>: An index error occurs when you place an index in bracket notation that does not exist in the sequence being referenced. For example, in the list <var>usernames = \["bmoreno", "tshah", "elarson"\]</var>, the indices are <var>0</var>, <var>1</var>, and <var>2</var>. If you referenced this list with the statement <var>print(usernames\[3\])</var>, this would result in an index error.
- <var>"TypeError"</var>: A type error results from using the wrong data type. For example, if you tried to perform a mathematical calculation by adding a string value to an integer, you would get a type error.
- <var>"FileNotFound"</var>: A file not found error occurs when you try to open a file that does not exist in the specified location.

## Debugging strategies  

Keep in mind that if you have multiple errors, the Python interpreter will output error messages one at a time, starting with the first error it encounters. After you fix that error and run the code again, the interpreter will output another message for the next syntax error or exception it encounters.

When dealing with syntax errors, the error messages you receive in the output will generally help you fix the error. However, with logic errors and exceptions, additional strategies may be needed.

### **Debuggers** 

In this course, you have been running code in a notebook environment. However, you may write Python code in an Integrated Development Environment (IDE). An **Integrated Development Environment (IDE)** is a software application for writing code that provides editing assistance and error correction tools. Many IDEs offer error detection tools in the form of a debugger. A **debugger** is a software tool that helps to locate the source of an error and assess its causes.

In cases when you can't find the line of code that is causing the issue, debuggers help you narrow down the source of the error in your program. They do this by working with breakpoints. Breakpoints are markers placed on certain lines of executable code that indicate which sections of code should run when debugging.

Some debuggers also have a feature that allows you to check the values stored in variables as they change throughout your code. This is especially helpful for logic errors so that you can locate where variable values have unintentionally changed.

### **Use print statements** 

Another debugging strategy is to incorporate temporary print statements that are designed to identify the source of the error. You should strategically incorporate these print statements to print at various locations in the code. You can specify line numbers as well as descriptive text about the location.

For example, you may have code that is intended to add new users to an approved list and then display the approved list. The code should not add users that are already on the approved list. If you analyze the output of this code after you run it, you will realize that there is a logic error:

<div id="bkmrk--3"></div><div id="bkmrk--4"></div>```python
new_users = ["sgilmore", "bmoreno"]
approved_users = ["bmoreno", "tshah", "elarson"]
def add_users():
    for user in new_users:
        if user in approved_users:
            print(user,"already in list")
        approved_users.append(user)
add_users()
print(approved_users)
```

```
bmoreno already in list
['bmoreno', 'tshah', 'elarson', 'sgilmore', 'bmoreno']
```

Even though you get the message <var>"bmoreno already in list"</var>, a second instance of <var>"bmoreno"</var> is added to the list. In the following code, print statements have been added to the code. When you run it, you can examine what prints:

<div data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" id="bkmrk--5" style="color: #000000; background-color: #fffffe; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"></div>```python
new_users = ["sgilmore", "bmoreno"]
approved_users = ["bmoreno", "tshah", "elarson"]
def add_users():
    for user in new_users:
        print("line 5 - inside for loop")
        if user in approved_users:
            print("line 7 - inside if statement")
            print(user,"already in list")
        print("line 9 - before .append method")
        approved_users.append(user)
add_users()
print(approved_users)
```

```
line 5 - inside for loop
line 9 - before .append method
line 5 - inside for loop
line 7 - inside if statement
bmoreno already in list
line 9 - before .append method
['bmoreno', 'tshah', 'elarson', 'sgilmore', 'bmoreno']
```

The print statement <var>"line 5 - inside for loop"</var> outputs twice, indicating that Python has entered the <var>for</var> loop for each username in <var>new\_users</var>. This is as expected. Additionally, the print statement <var>"line 7 - inside if statement"</var> only outputs once, and this is also as expected because only one of these usernames was already in <var>approved\_users</var>.

However, the print statement <var>"line 9 - before .append method"</var> outputs twice. This means the code calls the <var>.append()</var> method for both usernames even though one is already in <var>approved\_users</var>. This helps isolate the logic error to this area. This can help you realize that the line of code <var>approved\_users.append(user)</var> should be the body of an <var>else</var> statement so that it only executes when <var>user</var> is not in <var>approved\_users</var>.

## Key takeaways

There are three main types of errors you'll encounter while coding in Python. Syntax errors involve invalid usage of the programming language. Logic errors occur when the logic produced in the code produces unintended results. Exceptions involve code that cannot be executed even though it is syntactically correct. You will receive error messages for syntax errors and exceptions that can help you fix these mistakes. Additionally, using debuggers and inserting print statements can help you identify logic errors and further debug exceptions.

# Wrap-up

Great work in this section!  
We focused on a few new topics that will help you put Python into practice in the security profession.  
First, we explored opening and reading files in Python.  
Security analysts work with a lot of log files, so the ability to do this is essential.  
Next, we covered parsing files.  
Log files can be very long.  
For this reason, a structure in these files to make them more readable helps you automate your tasks and get the information you need.  
And last, we focused on debugging code.  
Knowing how to debug your code can save you a lot of time, especially as your code increases in complexity.  
Overall, I hope you feel proud of what you've accomplished in this section.  
Addressing security issues through Python is exciting, and the information we covered will allow you to do that.

# Reference guide: Python concepts from module 4

## <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">File operations</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">The following functions, methods, and keywords are used with operations involving files.</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">with</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Handles errors and manages external resources</span>

#### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("logs.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Used to handle errors and manage external resources while opening a file; </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">the variable </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> stores the file information while inside of the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> statement; </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">manages resources by closing the file after exiting the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> statement</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">open()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Opens a file in Python</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("login\_attempts.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">Opens the file </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"login\_attempts.txt"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> in order to read it </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">("r")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("update\_log.txt", "w") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">Opens the file </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"update\_log.txt"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> into the variable </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> in order to write over its contents </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">("w")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open(import\_file, "a") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">Opens the file assigned to the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">import\_file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> variable into the variable </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> in order to append information to the end of it </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">("a")</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">as</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Assigns a variable that references another object</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("logs.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Assigns the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> variable to reference the output of the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">open()</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> function </span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.read()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts files into strings; returns the content of an open file as a string by default</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("login\_attempts.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;"> file\_text = file.read()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts the file object referenced in the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> variable into a string and then stores this string in the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file\_text</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> variable</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.write()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Writes string data to a specified file</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("access\_log.txt", "a") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;"> file.write("jrafael")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Writes the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"jrafael"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> to the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"access\_log.txt"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> file; because the second argument in the call to the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">open()</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> function is </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"a"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">, this string is appended to the end of the file</span>

## <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Parsing</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">The following methods are useful when parsing data.</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.split()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts a string into a list; separates the string based on the character that is passed in as</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> an </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">argument; if an argument is not passed in, it will separate the string each time it encounters whitespace characters such as a space or return</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">approved\_users = "elarson,bmoreno,tshah".split(",")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"elarson,bmoreno,tshah"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> into the list </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">\["elarson","bmoreno","tshah"\]</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> by splitting the string into a separate list element at each occurrence of the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">","</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> character</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">removed\_users = "wjaffrey jsoto abernard".split()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"wjaffrey jsoto abernard"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> into the list </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">\["wjaffrey","jsoto","abernard"\]</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> by splitting the string into a separate list element at each space</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.join()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Concatenates the elements of an iterable into a string; takes the iterable to be concatenated as an argument; is appended to a character that will separate each element once they are joined into a string </span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">approved\_users = ",".join(\["elarson", "bmoreno", "tshah"\])</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Concatenates the elements of the list </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">\["elarson","bmoreno","tshah"\]</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> into the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"elarson,bmoreno,tshah"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> , separating each element with the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">","</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> character within the string</span>

# Terms and definitions from Course 7, Module 4

# Glossary terms from module 4

**Automation:** The use of technology to reduce human and manual effort to perform common and repetitive tasks

**Conditional statement:** A statement that evaluates code to determine if it meets a specified set of conditions

**Debugger:** A software tool that helps to locate the source of an error and assess its causes

**Debugging:** The practice of identifying and fixing errors in code

**Exception:** An error that involves code that cannot be executed even though it is syntactically correct

**File path:** The location of a file or directory

**Function:** A section of code that can be reused in a program

**Integrated development environment (IDE):** A software application for writing code that provides editing assistance and error correction tools

**Iterative statement:** Code that repeatedly executes a set of instructions

**Log:** A record of events that occur within an organization's systems

**Logic error:** An error that results when the logic used in code produces unintended results

**Parsing:** The process of converting data into a more readable format

**Syntax error:** An error that involves invalid usage of a programming language

**Variable:** A container that stores data

# Course wrap-up

As we wrap up this course, I want to congratulate you for your commitment to learning Python.  
You should feel accomplished having explored a programming language that's useful in the security field.  
Let's recap some of what we've learned.  
First, we covered basic programming concepts in Python.  
We discussed variables, data types, conditional statements, and iterative statements.  
These topics provided important foundations for what we explored later in the course.  
And our next focus was on writing effective Python code.  
We learned how we can reuse functions in our programs to improve efficiency.  
We explored built-in functions and even created our own user-defined functions.  
Another topic was modules and libraries.  
The pre-packaged functions and variables they contain can make our work easier.  
Last, we learned ways to ensure our code is readable.  
In the next section, we focused on working with strings and lists.  
We learned a variety of methods that can be applied to these data types.  
We also learned about their indices and how to slice characters from a string or elements from a list.  
We put all of these together to write a simple algorithm, and then we explored how regular expressions can be used to find patterns in the strings.  
And last, we wrapped up the course with a focus on putting Python into practice.  
We learned how to open, read, and parse files.  
With these skills, you can work with a variety of logs you will encounter in a security setting.  
We also learned how to debug code.  
This is an important skill for all programmers.  
Wow!  
You learned a lot about Python in this course, so great job!  
I hope soon you'll join me in using Python in the security profession.  
In the meantime, I encourage you to practice, and feel free to rewatch these videos whenever you like.  
The more you study these concepts, the easier they will become.  
Thanks again for joining me as we explored Python.

# Reference guide: Python concepts from Course 7

## <span style="font-size: 20pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Google Cybersecurity Certificate</span>

---

<span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Comments</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following syntax is used to create a comment. (A comment is a note programmers make about the intention behind their code.)</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\#</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Starts a line that contains a Python comment</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\# Print approved usernames</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Contains a comment that indicates the purpose of the code that follows it is to print approved usernames</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">""" </span><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(documentation strings)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Starts and ends a multi-line string that is often used as a Python comment; </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">multi-line comments are used when you need more than 79 characters in a single comment </span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"""</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The estimate\_attempts() function takes in a monthly</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">login attempt total and a number of months and</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">returns their product.</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"""</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Contains a multi-line comment that indicates the purpose of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">estimate\_attempts()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> function</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Conditional statements</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following keywords and operators are used in conditional statements. </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Starts a conditional statement</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if device\_id != "la858zn":</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Starts a conditional statement that evaluates whether the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">device\_id</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable contains a value that is not equal to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"la858zn"</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if user in approved\_list:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Starts a conditional statement that evaluates if the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">user</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable contains a value that is also found in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">approved\_list</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">elif</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Precedes a condition that is only evaluated when previous conditions evaluate to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; previous conditions include the condition in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statement, and when applicable, conditions in other </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">elif</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statements</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">elif status == 500:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">When previous conditions evaluate to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, evaluates if the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">status</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable contains a value that is equal to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">500</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">else</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Precedes a code section that only evaluates when all conditions that precede it within the conditional statement evaluate to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; this includes the condition in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statement, and when applicable, conditions in </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">elif</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statements </span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">else:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">When previous conditions evaluate to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, Python evaluates this </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">else</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statement</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">and</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Requires both conditions on either side of the operator to evaluate to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if username == "bmoreno" and login\_attempts &lt; 5:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Evaluates to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> if the value in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable is equal to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"bmoreno"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and the value in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">login\_attempts</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable is less than </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">5</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">or</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Requires only one of the conditions on either side of the operator to evaluate to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if status == 100 or status == 102:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Evaluates to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> if the value in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">status</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable is equal to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">100</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> or the value in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">status</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable is equal to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">102</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">not</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Negates a given condition so that it evaluates to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> if the condition is </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> if it is </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">if not account\_status == "removed"</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Evaluates to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> if the value in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">account\_status</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable is equal to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"removed"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and evaluates to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> if the value is the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">account\_status</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable is not equal to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"removed"</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Iterative statements</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following keywords are used in iterative statements. </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">for</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Signals the beginning of a </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">for</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> loop; used to iterate through a specified sequence</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">for username in \["bmoreno", "tshah", "elarson"\]:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Signals the beginning of a </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">for</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> loop that iterates through the sequence of elements in the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["bmoreno", "tshah", "elarson"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> using the loop variable </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">for i in range(10):</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Signals the beginning of a </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">for</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> loop that iterates through a sequence of numbers created by </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">range(10)</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> using the loop variable </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">i</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">while</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Signals the beginning of a </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">while</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> loop; used to iterate based on a condition</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">while login\_attempts &lt; 5:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Signals the beginning of a </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">while</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> loop that will iterate as long as the condition that the value of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">login\_attempts</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> is less than </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">5</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> evaluates to </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">break</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Used to break out of a loop</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">continue</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Used to skip a loop iteration and continue with the next one</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">User-defined functions</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following keywords are used when creating user-defined functions.</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">def</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Placed before a function name to define a function</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">def greet\_employee():</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Defines the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">greet\_employee()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> function</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">def calculate\_fails(total\_attempts, failed\_attempts):</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Defines the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">calculate\_fails()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> function, which includes the two parameters of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">total\_attempts</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">failed\_attempts</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">return</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Used to return information from a function; when Python encounters this keyword, it exits the function after returning the information</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">def calculate\_fails(total\_attempts, failed\_attempts):</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> fail\_percentage = failed\_attempts / total\_attempts</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> return fail\_percentage</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns the value of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">fail\_percentage</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable from the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">calculate\_fails()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> function</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Built-in functions</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following built-in functions are commonly used in Python.</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Outputs a specified object to the screen</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print("login success")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Outputs the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"login success"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the screen</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(9 &lt; 7)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Outputs the Boolean value of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the screen after evaluating whether the integer </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">9</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> is less than the integer </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">7</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">type()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns the data type of its input</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(type(51.1))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns the data type of float for the input of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">51.1</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(type(True))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns the data type of Boolean for the input of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">range()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Generates a sequence of numbers</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">range(0, 5, 1)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Generates a sequence with a start point of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">0</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, a stop point of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">5</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, and an increment of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; because the start point is inclusive but the stop point is exclusive, the generated sequence is </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">0</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, and </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">4</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">range(5)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Generates a sequence with a stop point of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">5</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; when the start point is not specified, it is set at the default value of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">0</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, and when the increment is not specified, it is set at the default value of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; the generated sequence is </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">0</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, and </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">4</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">max()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns the largest numeric input passed into it</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(max(10, 15, 5))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">15</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and outputs this value to the screen</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">min()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns the smallest numeric input passed into it</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(min(10, 15, 5))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">5</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and outputs this value to the screen</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">sorted()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Sorts the components of a list (or other iterable)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(sorted(\[10, 15, 5\]))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Sorts the elements of the list from smallest to largest and outputs the sorted list of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\[5, 10, 15\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the screen </span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(sorted(\["bmoreno", "tshah", "elarson"\]))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Sorts the elements in the list in alphabetical order and outputs the sorted list of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["bmoreno", "elarson", "tshah"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the screen</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">str()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Converts the input object to a string</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">str(10)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Converts the integer </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">10</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"10"</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">len()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns the number of elements in an object</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(len("security"))</span>

## <span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns and displays </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">8</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, the number of characters in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"security"</span>

##  

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Importing modules and libraries</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following keyword is used to import a module from the Python Standard Library or to import an external library that has already been installed.</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Searches for a module or library in a system and adds it to the local Python environment</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import statistics</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Imports the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">statistics</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> module and all of its functions from the Python Standard Library</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">from statistics import mean </span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Imports the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">mean()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> function of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">statistics</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> module from the Python Standard Library</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">from statistics import mean, median</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Imports the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">mean()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">median()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> functions of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">statistics</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> module from the Python Standard Library</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">String methods</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following methods can be applied to strings in Python. </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.upper()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a copy of the string in all uppercase letters</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print("Security".upper())</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns and displays a copy of the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Security"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> as </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"SECURITY"</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.lower()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a copy of the string in all lowercase letters</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print("Security".lower())</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns and displays a copy of the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Security"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> as </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"security"</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.index()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Finds the first occurrence of the input in a string and returns its location</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print("Security".index("c"))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Finds the first occurrence of the character </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"c"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"Security"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and returns and displays its index of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">List methods</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following methods can be applied to lists in Python. </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.insert()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Adds an element in a specific position inside the list</span>

<span style="font-size: 13pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list = \["elarson", "fgarcia", "tshah"\]</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list.insert(2,"wjaffrey")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Adds the element </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"wjaffrey"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> at index </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; the list becomes </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["elarson", "fgarcia", "wjaffrey", "tshah"\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.remove()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Removes the first occurrence of a specific element inside a list</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list = \["elarson", "bmoreno", "wjaffrey", "tshah"\]</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list.remove("elarson")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Removes the element </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"elarson"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> from the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; the list becomes </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["fgarcia", "wjaffrey", "tshah"\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.append()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Adds input to the end of a list</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list = \["bmoreno", "wjaffrey", "tshah"\]</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list.append("btang")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Adds the element </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"btang"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the end of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; the list becomes </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["fgarcia", "wjaffrey", "tshah", "btang"\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.index()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Finds the first occurrence of an element in a list and returns its index</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list = \["bmoreno", "wjaffrey", "tshah", "btang"\]</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(username\_list.index("tshah"))</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Finds the first occurrence of the element </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"tshah"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and returns and displays its index of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Additional syntax for working with strings and lists</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following syntax is useful when working with strings and lists. </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">+ </span><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(concatenation)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Combines two strings or lists together</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">device\_id = "IT"+"nwp12"</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Combines the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"IT"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> with the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"nwp12"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and assigns the combined string of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"ITnwp12"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the variable </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">device\_id</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">users = \["elarson", "bmoreno"\] + \["tshah", "btang"\]</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Combines the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["elarson", "bmoreno"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> with the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["tshah", "btang"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and assigns the combined list of </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["elarson", "bmoreno", "tshah", "btang"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the variable </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">users</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\[\] </span><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(bracket notation)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Uses indices to extract parts of a string or list </span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print("h32rb17"\[0\])</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Extracts the character at index </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">0</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, which is (</span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"h"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">), from the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"h32rb17"</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print("h32rb17"\[0:3\])</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Extracts the slice </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\[0:3\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, which is (</span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"h32"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">), from the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"h32rb17"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; the first index in the slice (</span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">0</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">) is included in the slice but the second index in the slice (</span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">) is excluded</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list = \["elarson", "fgarcia", "tshah"\]</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">print(username\_list\[2\])</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Extracts the element at index </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, which is (</span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"tshah"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">), from the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">username\_list</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Regular expressions</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> module function and regular expression symbols are useful when searching for patterns in strings. </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to a regular expression</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("a53", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["a53"\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\\w</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Matches with any alphanumeric character; also matches with the underscore (</span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\_</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">)</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("\\w", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"\\w"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to any alphanumeric character and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["a", "5", "3", "3", "2", "c", "E"\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Matches to all characters, including symbols</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall(".", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"."</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to all characters and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["a", "5", "3", "-", "3", "2", "c", " ", ".", "E"\]</span>

###  

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\\d</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Matches to all single digits</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("\\d", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"\\d"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to all single digits and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["5", "3", "3", "2"\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\\s</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Matches to all single spaces</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("\\d", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"\\s"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to all single spaces and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\[" "\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\\.</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Matches to the period character</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("\\.", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"\\."</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to all instances of the period character and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["."\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">+</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Represents one or more occurrences of a specific character</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("\\w+", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"\\w+"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to one or more occurrences of any alphanumeric character and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["a53", "32c", "E"\]</span>

###  

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\*</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Represents, zero, one or more occurrences of a specific character</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("\\w\*", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"\\w\*"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to zero, one or more occurrences of any alphanumeric character and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["a53", " ", "32c", " ", " ", "E"\]</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">{ }</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Represents a specified number of occurrences of a specific character; the number is specified within the curly brackets</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import re</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">re.findall("\\w{3}", "a53-32c .E")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Returns a list of matches to the regular expression pattern </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"\\w{3}"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a53-32c .E"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; matches to exactly three occurrences of any alphanumeric character and returns the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["a53","32c"\]</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">File operations</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following functions, methods, and keywords are used with operations involving files.</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Handles errors and manages external resources</span>

#### <span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with open("logs.txt", "r") as file:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Used to handle errors and manage external resources while opening a file; </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">the variable </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">file</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> stores the file information while inside of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statement; </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">manages resources by closing the file after exiting the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statement</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">open()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Opens a file in Python</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with open("login\_attempts.txt", "r") as file:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Opens the file </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"login\_attempts.txt"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in order to read it </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">("r")</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with open("update\_log.txt", "w") as file:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Opens the file </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"update\_log.txt"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> into the variable </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">file</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in order to write over its contents </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">("w")</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with open(import\_file, "a") as file:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Opens the file assigned to the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">import\_file</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable into the variable </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">file</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> in order to append information to the end of it </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">("a")</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">as</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Assigns a variable that references another object</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with open("logs.txt", "r") as file:</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Assigns the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">file</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable to reference the output of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">open()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> function </span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.read()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Converts files into strings; returns the content of an open file as a string by default</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with open("login\_attempts.txt", "r") as file:</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> file\_text = file.read()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Converts the file object referenced in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">file</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable into a string and then stores this string in the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">file\_text</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> variable</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.write()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Writes string data to a specified file</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with open("access\_log.txt", "a") as file:</span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> file.write("jrafael")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Writes the string </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"jrafael"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> to the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"access\_log.txt"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> file; because the second argument in the call to the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">open()</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> function is </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"a"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">, this string is appended to the end of the file</span>

## <span style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Parsing</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following methods are useful when parsing data.</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.split()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Converts a string into a list; separates the string based on the character that is passed in as an argument; if an argument is not passed in, it will separate the string each time it encounters whitespace characters such as a space or return</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">approved\_users = "elarson,bmoreno,tshah".split(",")</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Converts the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"elarson,bmoreno,tshah"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> into the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["elarson","bmoreno","tshah"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> by splitting the string into a separate list element at each occurrence of the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">","</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> character</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">removed\_users = "wjaffrey jsoto abernard".split()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Converts the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"wjaffrey jsoto abernard"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> into the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["wjaffrey","jsoto","abernard"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> by splitting the string into a separate list element at each space</span>

### <span style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">.join()</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Concatenates the elements of an iterable into a string; takes the iterable to be concatenated as an argument; is appended to a character that will separate each element once they are joined into a string </span>

<span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">approved\_users = ",".join(\["elarson", "bmoreno", "tshah"\])</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Concatenates the elements of the list </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">\["elarson","bmoreno","tshah"\]</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> into the string </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">"elarson,bmoreno,tshah"</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> , separating each element with the </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">","</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> character within the string</span>

# Terms and definitions from Course 7

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Algorithm: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A set of rules that solve a problem</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Argument (Python): </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The data brought into a function when it is called</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Automation:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> The use of technology to reduce human and manual effort to perform common and repetitive tasks</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">B</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Boolean data: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data that can only be one of two values: either </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">True</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> or </span><span style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">False</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Bracket notation: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The indices placed in square brackets </span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Built-in function:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A function that exists within Python and can be called directly</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">C</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Command-line interface: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A text-based user interface that uses commands to interact with the computer</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Comment:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A note programmers make about the intention behind their code</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Conditional statement: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A statement that evaluates code to determine if it meets a specified set of conditions</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">D</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data type:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A category for a particular type of data item</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Debugger: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A software tool that helps to locate the source of an error and assess its causes</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Debugging:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> The practice of identifying and fixing errors in code</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Dictionary data: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data that consists of one or more key-value pairs</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">E</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Exception:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> An error that involves code that cannot be executed even though it is syntactically correct</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">F</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">File path: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The location of a file or directory </span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Float data: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data consisting of a number with a decimal point</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Function:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A section of code that can be reused in a program</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">G</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Global variable: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A variable that is available through the entire program</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Immutable:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> An object that cannot be changed after it is created and assigned a value</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Indentation: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Space added at the beginning of a line of code</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Index:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A number assigned to every element in a sequence that indicates its position</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Integer data: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data consisting of a number that does not include a decimal point</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Integrated development environment (IDE): </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A software application for writing code that provides editing assistance and error correction tools</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Interpreter:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A computer program that translates Python code into runnable instructions line by line</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Iterative statement: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Code that repeatedly executes a set of instructions</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">L</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Library: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A collection of modules that provide code users can access in their programs</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">List concatenation:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> The concept of combining two lists into one by placing the elements of the second list directly after the elements of the first list</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">List data: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data structure that consists of a collection of data in sequential form</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Local variable: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A variable assigned within a function</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Log:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A record of events that occur within an organization's systems</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Logic error: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">An error that results when the logic used in code produces unintended results</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Loop variable: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A variable that is used to control the iterations of a loop</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">M</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Method:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A function that belongs to a specific data type</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Module</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">: A Python file that contains additional functions, variables, classes, and any kind of runnable code</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">N</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Notebook: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">An online interface for writing, storing, and running code </span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">P</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Parameter (Python):</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> An object that is included in a function definition for use in that function</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Parsing:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> The process of converting data into a more readable format</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">PEP 8 style guide:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A resource that provides stylistic guidelines for programmers working in Python </span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Programming:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A process that can be used to create a specific set of instructions for a computer to execute tasks</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Python Standard Library: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">An extensive collection of Python code that often comes packaged with Python</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">R</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Regular expression (regex):</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A sequence of characters that forms a pattern</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Return statement: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A Python statement that executes inside a function and sends information back to the function call</span><span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span><span style="font-size: 11pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> </span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">S</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Set data: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data that consists of an unordered collection of unique values</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">String concatenation: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The process of joining two strings together</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">String data:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> Data consisting of an ordered sequence of characters</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Style guide:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A manual that informs the writing, formatting, and design of documents</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Substring: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A continuous sequence of characters within a string</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Syntax: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The rules that determine what is correctly structured in a computing language</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Syntax error:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> An error that involves invalid usage of a programming language</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">T</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Tuple data: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Data structure that consists of a collection of data that cannot be changed</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Type error: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">An error that results from using the wrong data type</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">U</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">User-defined function:</span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> A function that programmers design for their specific needs</span>

<span style="font-size: 24pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">V</span>

<span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Variable: </span><span style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">A container that stores data</span>

---