Course Notes and Python tutorials

Source: Internet
Author: User
Tags define function

Course Notes and Python tutorials

Concise Python tutorial is a good entry-level Python tutorial on the Internet. Although the version is old, the basic explanation is very powerful.

Ch2-install Python: After downloading and installing Python, append the installation directory address to the Path variable in the system environment variable to use Python in cmd;

In the CH3-Python3, the print syntax is changed to print (); Python editor list; Python IDE list supported;

No special variable type definition process is required for the methane-variable;

CH5-Calculation Expression and priority;

CH6-control flow. The main control statement line ends with ":" at the end; if/while/for/break/continue usage;

CH7-use def fun (a, B): to create a function; use return to return the function value;

CH8-import/from... Import/; Use _ name _ to call the module name;

CH9-data structure, list, tuples, dictionary, sequence; string operations;

CH10-a Python script instance;

Ch11-define class ***

Define function def in the class **

Initialization class def _ init _ (self, x, y) self. x = x self. y = y

Inheritance class: class class2 (class1 ):

When you call the object MethodMyObject.method(arg1, arg2)This will be automatically converted from PythonMyClass.method(MyObject, arg1, arg2)-- This isselfWorking Principle

class Teacher(SchoolMember):    def __init__(self, name, age, salary):        SchoolMember.__init__(self, name, age)        self.salary = salary        print '(Initialized Teacher: %s)' % self.name

Ch12-file operation, file () is changed to open () in python3 ();

Read and print instances row by row;

    f = file('poem.txt')    while True:        line = f.readline()        if len(line) == 0: # Zero length indicates EOF            break        print (line)    f.close()

CH13-try .. else t .. else is used to handle exceptions, except t to indicate exceptions, and else To indicate normal conditions; try .. finally: indicates the final operation, regardless of the try result, will be executed finally:

Standard Library of CH14-Python: Use of sys. argv; use of OS module;

CH15-Python some special methods; assert statements;

_ Init _ (self ,...) # This method is called before the newly created object is returned for use. _ Del _ (self) # It is called just before the object is deleted. _ Str _ (self) # It is called when we use the print statement for the object or str. _ Lt _ (self, other) # called when the operator is smaller than (<. Similarly, all operators (+,>, and so on) have special methods. _ Getitem _ (self, key) # called when the x [key] index operator is used. _ Len _ (self) # Call the sequence object when using the built-in len () function.

CH16-advanced learning content


What should I do if I want to learn python programming?

If you are a beginner, we recommend that you first read
Both Learning Python and dive into python have Chinese versions.

Www.python.org is the official website of python. There is a lot of information you want on it. You can check it out more often, but it is a bit depressing for people who are not good at e.

It is best to use and learn a language. Therefore, you can download and install python at www.python.org.

After you get started, "Python in a Nutshell" is a useful reference book, so that you don't have to remember too many things (such as built-in functions or modules) and can read and find them at any time.

In addition, before you write a program, google it to see if similar modules have been written on the Internet, because some cool people in foreign countries often write some useful modules, reusing them will increase your programming speed

Go to the simple Python tutorial

The language details are basically enough for python generation python documentation. You can check python tutorial first. Then let's look at dive into python. I don't know what you mean by the intermediate stage level? But if you want to be a good programmer, there are few algorithms. But this is not related to python. You can use python to implement exercises in other language classes. This is a good exercise for beginners. Video, no need

Related Article

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.