Reasons to like Python:
The reason for liking Python is that Python is too handy to write. And like its modular programming program;
Python installation, and development environment:
Can be downloaded in their official website, I downloaded the comparison earlier, With a version of 2.73, the path path of Python is configured in the computer's properties, and the development environment is casual, you can write Python code using Notepad or another editor, run it under CMD, or use the python's own idle code.
Python's first program HelloWorld:
we create a. py file anywhere on the computer. Write a line of code inside the file
print ' HelloWorld ' to save this file
How to run it: You can find the path to run the. Py under CMD, or you can choose to open it and find Python idle to run the file.
Python's Modular Authoring:
Python's modular writing it's cool; you can divide a feature's implementation into multiple modules, put them in a Python file, and connect them together, and it's straightforward. Write an example;
I want to implement an addition and a subtraction function, and then call them;
First I create a folder called SRC. I wrote the. py file for my implementation of additions in the sums.py
Def _sum (A, B)
Sum=a+b
return sum
I'm creating a subtraction. py file subs.py
Def _sub (A, B)
Sub=a-b
Return Sub
Below we create a. py file to invoke the above method; Create a result.py file
Next we import the module:
In the result.py file, write the following code:
A= __import__ (' sums ')
b = __import__ (' subs ')
C=a._sum (10,20)
D=b._sub (20,10)
Print C
Print D
Run result.py, you can get the results, it is not very clear;
We can not use any editor, just download a Python interpreter, understand the Python language indentation style, you can easily write a Python program;
Python Basics "One"