The purpose of this document is to walk you through the process of setting up your computer for Python development and code submission in CS 149.

Downloading and Installing Thonny

The officially supported Integrated Development Environment (IDE) for this semester will be Thonny.

Download and run the appropriate installer for your operating system from https://thonny.org/. You should accept all of the default options during installation.

Revealing File Extensions

When naming files, there is a longstanding convention of using file extensions to indicate the type of information that the file contains. For example, a Windows executable might be named installer.exe, while a Word document might be named FinalReport.docx. In this case .exe and .docx are the file extensions indicating the file types.

In the good old days, these file exertions were visible by default, and they were often helpful in figuring out file types. Unfortunately, file extensions could also be confusing and intimidating for non-technical users. For example, .avi, .mp4, .mpg, .divx, .mov (among many others) are all file extensions that represent different kinds of video files. Understanding the differences between them is crucial to someone involved in video production, but irrelevant to someone who just wants to watch the video. In the interest of not confusing people, modern operating systems generally hide file extensions by default.

Now that you are a computer scientist, you have become the kind of person who needs to pay attention to file extensions. Congratulation! This means that you should modify the settings on your computer to show file extensions by default. Follow the instructions in the following links to change the appropriate settings on your computer:

Saving Files in Thonny and Submitting Through Gradescope

You will save yourself some trouble this semester if you get into the habit of organizing your Python files into folders organized by assignment. I suggest creating a top-level folder named CS149 that you can use to store each individual assignment folder. Watch the video below for an example of how this can be accomplished.

PEP8 - Python Style

When writing in English, readability can be impacted by the way the text is laid out on the page. We use conventions, like indenting the first sentence of a paragraph, to make it easier to understand written text. Programming languages are the same. Programs are easier to read if we agree on a set of conventions for how the code should be formatted. PEP 8 is the official document that describes the standard formatting conventions for Python code. (Here is a prettier version: https://pep8.org/.) You don’t need to read and understand the full PEP 8 document now, but you may want to look it over to get a feel for the issues that it addresses.

When you submit homework assignments for CS 149 they will automatically be checked against the PEP 8 formatting requirements using a tool named flake8. You will only receive full credit if you pass all of these automated style checks. You can install flake8 in Thonny by selecting Tools -> Manage Packages… and then finding and installing flake8 as well as pep8-naming. After installation, you should be able to check your file by typing the following into the Thonny shell:

>>> !flake8 hello_world.py

The exclamation point tells the Python interpreter the command should not be interpreted as Python code.

Note that the Gradescope autograder is configured to be slightly more lenient than the default settings for flake8. We allow line lengths up to 100 and disable checks for some errors and warnings. If you want to run flake8 with exactly the same settings as Gradescope, you can copy the following file into the same directory as your python code:

Video

Watch this short video for a demonstration of the steps required to create a new Python file, store it in a reasonable location, and submit it through Gradescope.

Back to Top