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: #. 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. Create a Trinket.io Account --------------------------- .. admonition:: Warning 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 `__. .. figure:: figures/trinket-signup.png :alt: 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. .. figure:: figures/trinket-home.png :alt: 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). .. figure:: figures/new-trinket.png :alt: Dropdown menus for creating a new Python Trinket. :width: 70% New trinket options. After you select the language, your new trinket opens! Click on *Untitled* to name your project, then use the *Save* button. .. figure:: figures/name-trinket.png :alt: A new trinket, with an arrow pointing out how to name it. :width: 70% 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: :: #!/bin/python3 This tells the editor to run the code as a Python 3 program. .. figure:: figures/python-version.png :alt: Screenshot showing how to add #!/bin/python3 to a trinket. :width: 70% 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. 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. .. figure:: figures/trinket-overview.png :alt: Trinket code editor layout 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.py`` file 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 ``main.py`` file. #. **Managing projects**: From left-to-right, the buttons allow you to: a. Move your project into a folder, b. Copy a project, which allows you to edit the code without changing the original, c. Share your projects with other users, d. Save changes to the project, e. 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. 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.