Basic Python notes-Introduction

Source: Internet
Author: User

I have never liked the animal "snake" since I was a child. In my eyes, it is always disgusting and terrible (Declaration: If I don't like it, it doesn't mean I want to kill it ). However, this does not affect my access to Python. When I see the word "Python", I don't think of "Python", but two Chinese characters: "Parson "...... @ % * XX ~ ^ 8 ...... J

In fact, I have noticed that the python official website http://www.python.org/does not have any pictures with the python as the topic. Facts have proved that my observations are correct. Python is named because the author prefers to watch the BBC's comedy movie Monty Python's flying Cirque, which has nothing to do with python.

---------------------------------------------------------------------------------

What is Python?

Python is a programming language. With the official website (http://www.python.org/) on the words is:Python is a dynamic object-oriented programming language that can be used for processing kinds of software development. it offers strong support for integration with other versions ages and tools, comes with extensive standard libraries, and can be learned in a few days. using Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code.(Translated by me:PythonIs a dynamic object-oriented programming language that can be used in a variety of software development. It provides powerful support for integration with other languages and tools, comes with a scalable standard library, and can be learned within several days. ManyPythonProgrammers reflect that it actually improves production efficiency, and feel that this language encourages higher quality development and more maintainable code .) According to my opinion, some of the advantages described in this section are indeed correct. I believe that as the notes go on, these will be interpreted slowly.

 

Don't chat. It is easy to go to the latest stable version of python on the official website. For MS Windows, you can download Windows Installer, which is generally included in Linux. After MS windows is installed, you can enable it in the Start menu, or start it in the console after cmd (maybe you have to set environment variables yourself ). In Linux, the python interpreter is usually installed under/usr/local/bin/python, and/usr/local/bin is placed in the search path of shell, and python can be started on the console. For details about installation, refer to the FAQ on the official website.

 

Let's look at the first example. "Hello, world" is always vulgar and useful at this time:

>>> Print "Hello, world !"

Hello, world!

This is a trial on the console. ">>>" This is a python prompt. When it appears, it indicates that the python console has been successfully started. The preceding statement is no longer simple: print is a command, "Hello, world !" As a command parameter, press enter to display the running result in the next row. Let's look at another example:

>>> 2 + 3*7-(3 + 4) * 8

-33

 

Haha, python is also very convenient for expression operations.

The two examples are not too simple. Let's look at an example with a slightly more elegant Syntax:

>>> Def buildconnectionstring (Params ):

... "Build a connection string from a dictionary of parameters.

... Returns string ."""

... Return ";". Join (["% s = % s" % (K, V) for K, V in Params. Items ()])

>>> If _ name _ = "_ main __":

... Myparams = {"server": "mpilgrim", "Database": "master", "uid": "sa",/"PWD": "secret "}

... Print buildconnectionstring (myparams)

After entering these information, you will see the console display:

Server = mpilgrim; uid = sa; database = Master; Pwd = secret

Well, the above example is actually quite simple, but you don't have to talk about it for the moment. So friends who like simple and straightforward can find concise and fluent expressions in Python, and friends who like gorgeous languages will not disappoint you.

As an informal introduction, it's time to get to know each other.

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.