Python Note (1) about whether or not we should continue to learn python-Python tutorial

Source: Internet
Author: User
For Python, if you want to learn, we suggest you check the website: because I have just decided to collect some time to learn about it, the recommendation may not be the best. I was asked during my previous interview. Are you familiar with linux? For this kind of question: I will always be embarrassed to answer, "I know something ".

However, when I graduated from college, I didn't even install linux virtual machines, let alone unfamiliar systems. Although I understand that this system can be operated entirely through commands. After work, sometimes I write some code and submit it to svn. the server is Linux and I am also running the client on windows. I remember a project that asked me to use shell to start the java program. do you know how I did it at that time? Take their shell and ask where to change it, and then change the path of the java class to be started. OK. I don't understand what it means. At the end of the interview, I had to confess: I don't know much about Linux commands.

Some may say that Linux commands are not difficult. It takes a few days. Now I will also say this to anyone who doesn't understand Linux. However, if I do not take the first step in learning commands. I have to wait for an interview for a long time in the future.
Back to the question, should we learn something that seems useless and is really good?
My answer is: if you do have a license and are willing to invest in yourself, I think it is necessary.
1. this extra study will enrich your weekend.
2. when learning to a certain extent, you will have a new view of things.
3. you have an extra chip during the interview.
4. there is a theory: the more you learn, the more you don't know. (The wider the knowledge, the larger the world you see !)

Like singing in a love song: "We have forgotten to go to a bridge and look at each other in our hearts." I wonder if we forget to go to a bridge, let's take a look somewhere else! Haha

So let's join in the PYTHON world!

Python notes (1)

For Python, if you want to learn, we suggest you check the website: (because I just decided to collect a bit of time to learn about it, the recommendation may not be the best)

Http://book.huihoo.com/pe-into-python/5.4_zh-cn/html/toc/index.html Dive to python
Http://docs.python.org/
Http://woodpecker.org.cn/
Http://code.google.com/intl/zh-CN/edu/languages/google-python-class/introduction.html

I think it's great to get started with python. because of installing a software, you can come to HelloWorld right away!
Maybe we are too old to be excited. In fact, I want to say that python is definitely a language that allows you to easily learn.

1. def is used for function declaration.

The code is as follows:


Def buildConnectionString (params ):



2. import Module: import

The code is as follows:


Import odbchelper



When importing a module, the python compiler goes to the path set by its environment variables to find this module. if the module to be imported is in a custom path, you must put this path in the environment variable first.

The code is as follows:


Import sys
Sys. path. append ('/my/new/path ')


3. if_else statement(Python uses indentation to control code blocks, replacing "{}" in java)

The code is as follows:


If n> 1:
Return n * fib (n-1)
Else:
Print 'end of the line'
Return 1


4. built-in data type List:
List li = ["a", "B", "mpilgrim", "z", "example"]

Use.

A. Use for var in list to traverse A list. Do not add or delete elements during traversal!

The code is as follows:


Squares = [1, 4, 9, 16]
Sum = 0
For num in squares:
Sum + = num
Print sum #30


B. Use in to determine whether an element is in the list:

The code is as follows:


List = ['Larry ', 'Curly', 'Moe']
If 'Curly 'in list:
Print 'Yay


C. list other methods:

The code is as follows:


List. append (elem) -- adds a single element to the end of the list. Common error: does not return the new list, just modifies the original.
List. insert (index, elem) -- inserts the element at the given index, shifting elements to the right.
List. extend (list2) adds the elements in list2 to the end of the list. Using + or + = on a list is similar to using extend ().
List. index (elem) -- searches for the given element from the start of the list and returns its index. throws a ValueError if the element does not appear (use "in" to check without a ValueError ).
List. remove (elem) -- searches for the first instance of the given element and removes it (throws ValueError if not present)
List. sort () -- sorts the list in place (does not return it). (The sorted () function shown below is preferred .)
List. reverse () -- reverses the list in place (does not return it)
List. pop (index) -- removes and returns the element at the given index. Returns the rightmost element if index is omitted (roughly the opposite of append ()).


D. Other examples of list:

The code is as follows:


List = ['Larry ', 'Curly', 'Moe']
List. append ('shemp') # append elem at end
List. insert (0, 'XXX') # insert elem at index 0
List. extend (['yyy', 'zzz']) # add list of elems at end
Print list # ['XXX', 'Larry ', 'Curly', 'Moe', 'shemp', 'yyy', 'zzz']
Print list. index ('Curly ') #2

List. remove ('Curly ') # search and remove that element
List. pop (1) # removes and returns 'Larry'
Print list # ['XXX', 'Moe', 'shemp', 'yyy', 'zzz']


The purpose of this article is to allow more people to learn things they may refuse to learn through various excuses.
I hope you will be inspired by me and take some action!

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.