Skip to main content
  1. Teaching/
  2. teaching/

·4 mins

Assignment 0

Getting Set Up With Tooling

In principle, you could write code with nothing but a pencil and paper. In practice, having good software tools is a huge help. Good tools can make it much more pleasant to write code, help catch mistakes early, and, in very limited cases, even write code for you.

In this class, we will use an integrated development environment (IDE) to write code. These give you everything you need to write code in one convenient package. Your task for this homework is to download, install, and get used to working with an IDE.

If you do not already have an IDE installed, I recommend that you use PyCharm Community Edition [1]. The rest of this assignment will give you instructions for downloading and running programs in PyCharm.

Install Python

If you are on a MacOS machine, Python 3 comes pre-installed.

If you are on a Windows machine, visit [the Windows App store][https://apps.microsoft.com/store/detail/python-310/9PJPW5LDXLZ5?hl=en-us&gl=us] and download Python 3.10. Once the store app says that the install has completed, open up an instance of PowerShell (you can search for "PowerShell" in the start menu if you don't know where it is), and then type python3 into PowerShell to run the Python interpreter. You should see an output that looks something like this:

setup.png

If you can see this, you are ready to run Python!

You might also want to run the following command to install the IPython shell, which will be used later in the course:

pip3 install --user ipython

If you are on Windows, you can access the command terminal to run this command by opening the start menu and searching for "Powershell". On MacOS, hit Cmd+Space and search for "Terminal" instead.

Install PyCharm

To install PyCharm, visit their website and click "Download." You will want the community version, not the Professional one. The professional version costs $250 a year and is not necessary for this course, since all the features we need are available in the free community version.

Download PyCharm Community and install it.

Write a script

Once you have installed PyCharm, launch it and create a new project. If you get the homescreen, you can do this by clicking on "New Project." Otherwise, you can do this by clicking on "File" and then "New Project."

Make sure to uncheck the "Create a main.py welcome script" before clicking "Create."

Click on "Project" in the upper-left-hand corner of the window, then right click on the directory name, then select "New > Python File." Name this file "Hello.py".

This will open Hello.py in the main Python interface. Write a simple "Hello World" program like we did in class. Then, add a new line that prints your name.

In the top right of the window, click on "Add Configuration". Click one of the buttons to add a new run configuration and select "Python". Click on the folder in the bar, and select your Hello.py file.

This should let you run your script by clicking on the green arrow in the upper right of the window. Make sure you can do this.

Also, make sure you can run the script in the terminal. You can use Alt+F12 to open the terminal, or use Ctrl+Shift+A (Cmd+Shift+A on MacOS) to open the command palette, then type "Terminal".

In the terminal, run "python3 Hello.py" and make sure you see the output you expect.

Run the sample script

This assignment comes with a script called armored.py. Download it and place it in your project directory.

Download armored.py here.

NOTE: Usually, you absolutely should not run a script that looks like this, since this sort of obfuscation is a technique to hide malicious code. However, in this case, I promise you that it doesn't do anything bad.

Run armored.py however you like (either by running it in the terminal or by generating a custom configuration for it the same way we made one for Hello.py).

The script will ask you for some input and then respond. Try several inputs to figure out what it is doing. Once you think you know what the script does, you can stop.

Submission

On Canvas, submit a short description (3-4 sentences) of what the mystery script does. You should also upload your copy of Hello.py.


  1. If you are going to choose to use something else, you should email me to let me know what editor and operating system combination you plan to use (e.g. VSCode on Windows) so that I can prepare for this. You should also have at least some knowledge in how to use your tooling of choice, since I might not be able to help you with certain problems. ↩︎