[Python ②] first show in python, python

Source: Internet
Author: User

[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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.