Python Tutorial for Mac
- 1
The Python language offers a gentle introduction to programming.Chad Baker/Ryan McVay/Photodisc/Getty Images
Open the terminal application. Go to the applications folder, then go the utilities folder, then double-click on the terminal application. A small window with a prompt with the name of your computer followed by the dollar sign will open up. It should look something like this:
My-Mac Book-Pro:~ user$ - 2
Ready. Set. Program!Ryan McVay/Photodisc/Getty Images
Start a Python session by typing the word Python right after the blinking dollar sign, then hit the return key. It should look like this:
My-MacBook-Pro:~ user$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
This tells youwhich version of Python you are running. The >>> is the Python prompt. You are now ready to run some commands. - 3
Python gives you a new blackboard for basic arithmatic.Photos.com/PhotoObjects.net/Getty Images
The classic first program calls for the program to output "hello world." You can do that with just one line of code, the print command:
>>>print "hello, World!"
Type exactly what you see above, then press the return key, and you should see this:
>>> print "Hello, world!"
Hello, world!
>>> - 4
This tutorial is just a drop in the ocean of possibilites Python offers.Jupiterimages/liquidlibrary/Getty Images
You can also perform some basic arithmetic calculations. Add numbers like this:
>>> 46 + 1964
Then press the return key. You should see this:
>>> 46 + 1964
2010
>>>
When you are finished, you can end your Python session by typing quit() and then pressing the return key. This will return you to the system prompt, exactly where you started when you opened the terminal application:
>>> quit()
My-MacBook-Pro:~ user$