专业英语笔记:Install and Use Python
专业英语笔记:Install and Use Python
Python was created in 1991. It has been espcially popular in recent years.
Since Python is so popular and useful, we need to learn something about Python programming.
Download Python from its official website.
Create a new folder python at c:\.
Double-click the Python installer and install Python at the location of C:\python.
First let's start the command-line Python from the start-menu.
You will see a DOS window and the Python prompt: >>>
Now we can use Python in an interactive manner.
This manner is very convenient for us to learn Python grammar.
Task 1. Print a message on the screen.
Task 2. Complete the addition of two integers.
The interactive manner in Python is similar to that in Visual Basic.
Task 3. Take different actions according to the age input from the keyboard.
Let's complete the same in another way. We can write a Python program to do this.
All roads lead to Rome. 条条道路通罗马。
Now let me start IDLE from the start-menu as follows:
We will see a Python shell on the screen:
Firstly, let me try the interactive manner here.
Secondly, let me complete the same task in program manner.
Click File menu, choose New File, and you will see an editor window like this:
Now we can write codes in the text editor as follows:
Save the file to a Python program with the extension of ".py".
Run the Python program "addition.py".
Now we modify the source program so we can input two integers from the keyboard and calculate its sum.
Run the program again and we can something like this:
Where is the Python program - addition.py?
What shall we do to run a Python program if we don't use the IDLE?
1. start DOS window
2. enter the directory c:\python_work
3. Run the python program addition.py