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:
To provide a space to practice quick tasks and examples found in the reading.
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.
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.
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).
After you select the language, your new trinket opens! Click on Untitled to name your project, then use the Save button.
188.8.131.52. 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.
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.
Features to note:
File tabs and options: Allows you to select, add, upload, or delete files. Clicking on the 3 bars also reveals extra options, like Settings.
Editor panel: Your code goes here. Click on a tab to open it in the editor. For new Python projects, a
main.pyfile will be created and opened by default.
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.
Run button: Executes any code written in the
Managing projects: From left-to-right, the buttons allow you to:
Move your project into a folder,
Copy a project, which allows you to edit the code without changing the original,
Share your projects with other users,
Save changes to the project,
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!¶
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.