Computers are simple creatures. Simple creatures that can be told to do very complex tasks. If you break a problem down far enough you can represent it as a simple series of yes or no questions. If “statement” do “something”, else do “something else.”
Ok, lets begin.
1. Start by opening up the terminal and typing idle3
and hit enter.
2. Now click file and then new file.
3. Lets start by defining a simple variable.
apples = 5
4. Now type
if apples < 10:
print("You have less than 10 apples")
else:
print("You have way too many apples!")
5. Good! Now save the file. I recommend saving it to the desktop so you will be able to find it easily in the terminal.
6. Ok, now open up a new terminal window and type ls
then press enter.
7. You should see something like this: Yours will probably look a bit different, that’s ok! I just have a program called “Oh-my-zsh” installed.
8. Next type cd Desktop
and hit enter. Then type ls
again.
9. You should see the file you just created somewhere in the list of items on your desktop. If you type python3 your-file-name.py
inserting the name of your file for “your-file-name” and hit enter.
10. If you see “You have less than 10 apples” printed out to the terminal like this then you did it right!!
11. I’m so proud of you, you’re growing up so fast.