[Python ②] first show in python, python
First python Program
Note: All subsequent codes are written in Python 3.3.2 (running environment: Windows7.
After installing and configuring python, we will first write the first python program. Open IDLE (Python GUI) or open python in your installation directory. py. If the path has been configured according to the instructions in [python ①], open cmd and directly enter python. In actual use, a text editor is generally used to write code. After the code is written, it is saved as a file for convenient modification. You must never use Word or notepad that comes with Windows. Word saves a non-plain text file, and notepad adds a few special characters (UTF-8 BOM) at the beginning of the file, the result will cause program running error.
Sublime Text or notepad-plus can be used. Of course, python compiler can also be used.
Official website address: http://www.sublimetext.com/(English interface, but the background is cool, you can set)
Http://notepad-plus-plus.org/(Chinese version, suitable for English is not very skilled)
Run the command in cmd:
Of course, we usually use the built-in editor after python installation. Open IDLE (Python GUI) and press the shortcut key Ctrl + N to bring it up. After writing the code, press F5 Run Module.
Summary of the day
Write and save python_hello.py in multiple ways, and compile the first python program at the same time.
If else in python basic tutorial, why is the else not aligned with if ??
This else statement corresponds to the for statement, not the if Statement, which is unique to python.
That is, in the for loop, if you do not exit from any break, the corresponding else
As long as it exits from the break, the else part is not executed.
If C ++ is used to implement this section, you can see the usefulness of for-else by comparing it as follows.
For (I = 99; I> 81; I --)
{
N = sqrt (I );
If (n = int (n ))
{
Cout <I;
Break;
}
}
If (I = 81) // boundary judgment
Cout <"didn't find it! "<Endl;
Python and activepython
Generally, Python is a programming language, and activepython is a Python programming and debugging tool. python is the basis of activepython.