2.5. Trinket.io

Repl.it and Trinket.io are free online code editors, and they both provide a practice space to boost your programming skills.

For this class, the sites serve two purposes:

  1. To provide a space to practice quick tasks and examples found in the reading.
  2. To hold larger exercises and projects that will be checked for accuracy and tracked for completion.

2.5.1. Create a Trinket.io Account


Before signing up for a Trinket account, be sure your school has approved the site for student use!

Create a new student account with Trinket here.

Trinket.io sign-up screen.

After you sign in, you will see your Home screen, which displays your recent work and course options. Since you are just starting out, you won’t need to do much on this screen.

Trinket.io home screen.

Home screen

Click on the New Trinket button to begin a new project. You can also access this option from the username dropdown menu. Scroll through the language options and select either Python (free account) or Python3 (paid account).

Dropdown menus for creating a new Python Trinket.

New trinket options.

After you select the language, your new trinket opens! Click on Untitled to name your project, then use the Save button.

A new trinket, with an arrow pointing out how to name it.

Name your new project! Trinket Python Versions

Trinket allows users to code in both Python versions 2 and 3, but some of the latest version 3.x features are not supported with a free account. However, the free service will work just fine for this course (which focuses on versions 3.6 and later).

From time to time, you may notice that the exact same code behaves differently in your saved trinkets compared to the examples found in this book. When this happens, it is probably due to a version conflict. You can fix the issue by adding a special line of code to the top of your saved trinkets:


This tells the editor to run the code as a Python 3 program.

Screenshot showing how to add #!/bin/python3 to a trinket.

Adding #!/bin/python3 to a project. Note the small difference in the two outputs. The bottom result is what we expect from Python version 3.x.

2.5.2. The Trinket Workspace

Now let’s take a look at how to use Trinket. The workspace consists of two main panels, one hidden panel, and several menu functions.

Trinket code editor layout

Features to note:

  1. File tabs and options: Allows you to select, add, upload, or delete files. Clicking on the 3 bars also reveals extra options, like Settings.
  2. Editor panel: Your code goes here. Click on a tab to open it in the editor. For new Python projects, a main.py file will be created and opened by default.
  3. Console panel: Any output produced by your code will appear in this panel. The console also displays error messages, test results, and other information. Also, by clicking on the Instructions tab, you can include steps for other users to follow.
  4. Run button: Executes any code written in the main.py file.
  5. Managing projects: From left-to-right, the buttons allow you to:
    1. Move your project into a folder,
    2. Copy a project, which allows you to edit the code without changing the original,
    3. Share your projects with other users,
    4. Save changes to the project,
    5. Delete the project completely.

If you are viewing someone else’s project, you will also see a Remix button. Clicking Remix saves a copy of that project to your own account. This lets you use other programmers’ work (with permission) to enhance your own.

2.5.3. Try It!

Repeat your Hello, World! program in the editor. Be sure to save your work! If you forget to click Save, you will lose the new changes when you logout or refresh the page.

At any time, you can return to a list of your saved projects by clicking on the My Trinkets link next to the project name.