Written By: Naomi Gong
Atom is a code and text editor that allows you to write lines of code for software, web development, or most coding projects that you desire. You can then import your code into Terminal on Mac to run your code. It's an efficient tool, as Terminal doesn’t allow you to edit lines directly, so a third-party editor is needed for programming. Atom can help you organize your code through color coding, and by naming the folder it recognizes the coding language.
Let’s write a simple code together, but first you need to download the Atom Text Editor.
To download Atom click here: https://atom.io/
Now that you have downloaded it, let's write a simple program that will tell Python countdown to blastoff.
1. Open Atom. This might look a little confusing, but I will walk you right through it.
2. Click ‘File’ at the top of your Mac, and then click on ‘New File’. This will open a new tab on Atom.
3. Title it by clicking ‘File’ again, but this time click "Save”. This will allow you to select a folder to save it at and name the untitled project. I recommend making a folder just for your codes. In my case, I named my folder ‘python’ and put it under the ‘documents’ folder. Name the title whatever you want then end it with ‘.py’. For example, I will name my file lukupp.py. This helps atom recognize that this is a python code.
4. Now you can start typing your code.
Here is my code:
5. When you are done, save it by clicking ‘File’ and ‘Save”.
6. Open Terminal, now we must tell Terminal to retrieve it for the folder that were created.
Once I open Terminal, I will type ‘cd documents’. Terminal will then prompt me with the next line. I will type ‘cd python’. It will prompt you for a command. I will type python3, indicating my coding language/version. Then type the file name.
In total this is what I have typed in Terminal:
cd documents
cd python
python3 lukupp.py
7. Terminal will now run your code that was saved under the file name!
8. If your code has an error, Terminal will prompt you for which lines contain those errors. Unfortunately, we cannot fix these errors in Terminal, but that is what Atom is for! To rerun, just follow steps 4-7 again. Good luck coding!
Comments