The third day of Python 3 learning--python Basics

Source: Internet
Author: User
Tags extend true true

The third day of Python learning

Write this blog to motivate yourself and share your experiences and issues with others.

First, class notes

1. (previous section Review) multiline comment ""--another function is to print multiple lines; ""--the quotation marks can only be printed on a single line. Add a variable which is more than one line, without adding a variable it is a multiline comment. In Python, single and double quotes have the same meaning.

Use of 2.Pycharm: Development tools use ide--intergrated development environment

VIM # Classic Linux under the text editor small white and Daniel with ...

Emacs # The text editor under Linux is easier to use relative to vim.

Eclipse # Java IDE, support python,c,c++

Visual Studio # Microsoft-Developed IDE support Python,c,c++,c#,java

notepadd++

Sublime # Python developed the

Pycharm # mainly used in Python development

It is recommended to use Pycharm. interpreter--Interpreter

3. Character formatting output

Placeholder:%s s string

%d d digit integers

%f F Float floating point

            

4. Data operations

Digital

integer int

Plastic

Long Plastic

The shaping of the long shape is not differentiated in Python3.

There are only two states of the Boolean type

True True

False false

String

"XXXXX" which is the string string concatenation efficiency is very low preferably not "+" to splice, it is best to use "%s" this to use.

   

In a computer, everything is an object. All things in the world are objects, all objects can be classified. --Object Oriented programming core

5. For loop

Finite cycle

Basic syntax: For I in range (3):

Print (i)

Infinite Loop (for loop only finite loop) refers to while loop

While True:

Xxxxx

6.range (x, Y, z) takes from X. to Y-1. The step is Z.

7. Double break jump with flag bit

    

8. List

List: a = []--generates an empty list

Check-----slices: Take out each item in the list

A [1:4]--the second element in the list and the third element and the fourth element 0 1 2 3 4; If you want to take the last element: no numbers;

A [: -1]--the last one does not take, -2 is the last two, if [A:b],a is negative, then from the bottom of the first to start from a backward, and finally B does not take;

A [a:b:c]--c means to take one from the beginning of index A, one by three. The first element is the second element. c If it is negative, it is taken from right to left;

    

Increase-----Append and insert: Adding elements to a list

A.append (' xxxx ') adds XXXX to the last face of the list

A.insert (A, ' B ') inserts an element into the index position (starting at 0) A is the location of the insertion, B is the content

The repair-----is deposited by another assignment operation.

A[1] = ' Liufeiduo '

Delete----remove pop and del

A.remove (' content ') remove the content directly, you can also put in a[0] this to represent

A.pop (x) x is the index value, and a pop is returned to the value after it has been deleted. b = A.pop (1) b can accept the deleted value

Del A[0] or del a directly deleted, how to delete how to delete

Common methods for other lists:

      Count: counts the number of occurrences of an element in a list A.count (2)

      Extend: Appends the value of another list to the end of a list a.extend (b) Put the elements inside b[] inside the a[]

      Index: find location A.index (' XXXX ') based on content find the location of the element xxxx

      Reverse: sort the elements in the list in reverse order A.reverse

      Sort : sorting elements, pressing ASKII code from large to small sort can change parameter a.sort (reverse = True) to sort from small to large a.sort ()

      

Second, experience

  Through another new chapter of the study of the Python language has a preliminary understanding, has been able to write some idiot program, through the judgment loop to achieve some basic functions, but the progress of learning is always a problem, not to the desired speed. Feel some once have the foundation of something can absorb faster, later can be in the implementation of the specific code two times to study, so will learn a bit more solid, this is the current idea may be biased.    

  

  

     

The third day of Python 3 learning--python Basics

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.