Start IDLE from the terminal
To open IDLE:
- Open a terminal window.
- In the terminal window, issue the command idleX.Y (for example: idle2.7) to launch IDLE*.
- Click Python-> Preferences… Menu item.
- Click General
- In startup Preferences part, click Open Edit Window radio button.
- Click Ok
Then can see the edit window and edit your Python code in the edit window.
*Note: IDLE (Integrated Development Environment or Integrated Development and Learning Environment) is an integrated development environment for Python.
Create a folder for your own Python program file
To create a folder to save your Python program file:
- Go to Macintosh HD (your hard drive name. your hard drive might have a different volume name)
- Click Users folder
- Create a folder named python_code (you can use a different name for this folder).
The extension name for Python is .py.
Enter Python interpreter
- Click the edit window to activate editing window for Python
- Click Run-> Python Shell Menu item
Now you can see the windows of Python interpreter, and it is called Python version_nember Shell.
Try Some Simple Python command
You can try some command in the Python Shell window, and have a feeling how Python interpreter works.
>>> print (‘Hello’)
And type enter.
You will see:
>>> print(‘Good Morning!’)
You will see
Create a python program file
Click the edit window to activate it. Type the following code:
x = 2
print(‘x = 2’)
y = 3
print (‘y = 3’)
z = x+y
print(‘Please tell me the result of s+y’)
print(‘The result of x+y is: ‘)
Save the code into a file named mypython1.py into the folder python_code taht you created earlier.
Run a python program inside Python interpreter
Open your python interpreter. Type:
Then press enter.
You can see the result of your scripts like this:
x = 2
y = 3
Please tell me the result of x+y
The result of x+y is:
Now you are able to open Python interpreter, writer a small Python program, run your Python program inside Python interpreter, and you can also run simple command inside Python interpreter.