streda 23. decembra 2015

Python 3 Tutorial (Mac) p.1

    Hello,  I am back again with another tutorial. I was doing only tutorials for HTML and CSS and one for Batch, so I managed to do series of tutorials to Python 3. Ok, let's get started.

Installing

If your computer runs on some modern and actualized Unix system or Mac OS X, it is chance that you have Python already installed. Just to be sure, open Console (Unix) or Terminal.app (Mac) and type in command python3 -V. If your computer sais that you don't have it installed. Go to https://www.python.org/downloads/ and choose on which platform do you want to install (Mac, Linux, Unix, Windows, etc.). The next installation steps are simple, just open and click Next, Next, Next, Next, and Finish. You just installed Python.

First Program

Open Finder, go to Documents and create a file named py3eg. Than open this file in your text editor and create new file. To your text editor type in this code: 
print ("Hello world!")
Save this file as hello.py to py3eg folder. Than open Terminal.app and type in command: 
cd Documents/py3eg
This command will get you in the py3eg folder. Than type another command saying ls. This command will show up all files that you have in that folder. In your case it will show just one file: hello.py. Now, type in last command saying python3 hello.py. This command will launch the file. Under this line, text saing Hello World! under the command.