Google Colab
This is the new way to get a Python environment in the cloud, including an AI to help write your code.In a browser, go to
https://colab.research.google.com/If you see a blue "Sign In" button at the top right, click it and log into a Google account.From the menu, click File, "New notebook".
https://tio.run/#python3In the Code section, enter this code:
print("Hello, World!")
At the top left, click the
triangle-in-circle icon to
run your code.
The Output section shows the result, as shown below.
Flag VP 10.1: Help (2 pts)
Run this code:The flag is covered by a green rectangle in the image below.
help()
import requests
r = requests.get("https://samsclass.info")
At the top left, click the
triangle-in-circle icon to
run your code.
The program fails, with errors, as shown below.
This online Python sandbox doesn't allow sending network traffic. You can use it for some of the challenges, but not all of them.
To see if you already have it, execute this command in a Terminal or Command Prompt window:
python3
If you see a Python version number starting
with 3, as shown below, you have Python 3
installed already.
Enter this command to exit the Python interpreter:
exit()
If Python 3 is not already installed, follow the instructions in the gray box below to install it.
Installing Python 3 on a Mac
Follow the instructions below: https://www.maketecheasier.com/using-python-3-on-mac/
Installing Python 3 on Windows
Download te latest version here:https://www.python.org/downloads/Start the installer. At the bottom of the first window, check the "Add Python 3.9 to PATH" box, as shown below.Then click Install Now.
Linux or Mac
In a Terminal window, execute this command:Enter this text, as shown below:
nano hello.py
print("HELLO")Press Ctrl+X, Y, Enter to save the file.
Then execute this command to run the program:
It prints out "HELLO", as shown below.
python hello.py
Windows
In a Command Prompt window, execute this command, as shown below.A box pops up asking "Do you want to create a new file?". Click Yes.
notepad hello.pyIn Notepad, enter this code, as shown below.
print("Hello, World")In Notepad, click File, Save to save the file.
In the Command Prompt, execute this command, as shown below.
The program runs, printing out "Hello, World!", as shown below.
python3 hello.py
Flag VP 10.2: Requests (8 pts)
Execute this command to install the "requests" library:
python3 -m pip install requestsThen run this program:
"error: externally-managed-environment"
If you see this error message, you need to create a Python virtual environment with these commands:
python3 -m venv venv source venv/bin/activateThe flag is covered by a green rectangle in the image below.
import requests r = requests.get("https://samsclass.info") print(r.status_code)