Python entry-level trial (A simple tutorial)

 Statement: Concise Guide to learn Python

Written in Python traditional 'Hello World' program. Using Python to run your program in two ways: using the interactive interpreter prompt or using a source file. Now we look at how to use both methods.

First, the use of interactive interpreter prompt (>>>)

1, an example system using windows 7: win + R start command window as shown below:

Input cmd ---> ENTER -> python, as shown below:

 

 

 Input python ---> ENTER, as shown below:

 

 

 

Here you should see >>>, then you can enter content in there. This is called the Python interpreter prompt.

Python interpreter prompt, type: print ( "Hello World"), and then press the [ENTER] key. You should see the words Hello World on the screen. As shown below:

 

 How to exit the interpreter prompt: Enter exit () ---> Enter.

 

Second, use the source file output Hello World

  Just a question: if we are to have programs written thousands of lines, we use the editor to prompt a run after the preparation is complete, we want better results, the result of running the event is not what we want, so we have to re-edit the program, but also a million lines of code on thousands of lines, who can guarantee that the code can be written and the last written exactly the same, besides the program we have to continue with the preparation of new and used. How to solve this problem? A: using the editor.

We use PyCharm Educational Edition  This is a free editor, you can use it to write Python programs. As shown below:

 

Run the file, as shown below:

 

 

 Operating results as shown below:

 

 

Third, get help
if you need quick information about any function or statement in Python, then you can use the built-in help function. This is very useful, especially when using the interpreter prompt.

 比如,运行 help('len') —— 这将会显示 len 函数的帮助,该函数用于计算项数。如下图所:

 

 提示:按下 q 退出帮助。如下图所示:

 

 类似地,你可以获得关于 Python 中几乎所有内容的信息。可以使用 help() 了解更多关于 help 本身的用法!

如果你需要获得像 return 这样的操作符的帮助,那么你需要将他们放在引号里面,像这样 help('return') 如下图所示:以便 Python 不会对我们要做的事情感到困惑。

 

 

Guess you like

Origin www.cnblogs.com/liunaixu/p/12364856.html