Looks like for this challenge we will be using some Python3. Make sure you have python 3 installed. Since I am on a Linux machine I can just run python3 to verify.
Python is a really powerful language. You can use it to automate various tasks or create your own exploits. Once you get the hang of it, the language is pretty easy to use.
First for the exercises we will make a hello world program.
Open up your text editor of choice, I will be using nano.
nano HelloWorld.py
In there, define your function. Remember when you make these programs you need to use tabs OR spaces. If you interchange them it will cause issues when you run the program.
def hello():
print(“Hello, World!”)
hello()
Now we can run the program with python3 HelloWorld.py. On the first line we define a function. Then we say what the function will do. Finally we call the function.
There’s a lot of great information about various python features, so I suggest going through all the information provided by TryHackMe.
Now we have the first question around the output of True + True.
type python3 in your terminal to drop into a python shell.
Then type True + True and hit enter.
We can see True + True = 2.
Now we need to know the output of bool(“False”).
Type that into a python terminal and you get True.
The next question is what library lets us download the HTML of a webpage. If we search up in the tutorial we can see requests is the library that allows us to do that.
Now we need to understand what the code does. If you look at the code, we are adding the value of 6 to a dictionary in y. We can type it out into a python3 terminal to verify the out which will be [1, 2, 3, 6].
If we look above, we see pass by reference in bold. Since we are passing a location of a variable in when we append (6). We are saying that the value of 6 needs to go at the end of the list. We know it is a list due to the brackets [].
That was a really quick into to python! Let’s move onto Day 16.