In Python learning, good memory is not as good as bad writing.

Source: Internet
Author: User

This article shows the blog posts written by vamei to the bloggers.

1. type () can display the parameter type, for example, a = 12 type (a) is int

2. the basic type of python is int float bool string such as int: I = 1, float: f = 12.5, bool: B = True or Flase, string: s = 'hello, word! 'No need to declare the type, that is, the dynamic type, before use

3.1 sequences include tuple and list. the tuple statement cannot be changed to s = (1, '3', True, (1, 2, 3 )) subscript starts with 0 s [0] as 1 s [3] [1] As 2 list declaration method is s = [1, 2, 3] can be nested value assignment change Delete and other operations

3.2 sequence subscript technique s [0: 3] means the last element of list from 0 to 2 (excluding 3) s [-1] list

3.3 string is tuple

4. operations include +,-, *,/, % addition, subtraction, multiplication, division, and remainder.

2) Yes = ,! =, <, >,<=, >=Equals, not equal to or less than, greater than, less than or equal to, greater than or equal ....

3) logical operations include and, or, not and, or not, that is, 1. are true. 2. One or more of them are true. 3. Reverse Lookup

5. Python uses a Tab as the indent (Tab) to indicate the indent relationship in the code below:

1  def Helloword():2      for i in gange(5):3          print('Hello word ',i)

2) def for while if else and other definitions are required: otherwise, the indentation print will be wrong, indicating that the statement is in the for statement.

6. while loop judge false Value Stop Loop

i=5while i :    print(i)    i=i-1 

For Loop record Loop

For I in range (5): # gange returns a list. in to traverse the print (I) sequence)

If select Loop

1 if I <0: 2 print ('I is less than 0') 3 else: 4 print (' I is greater than or equal to 0 ')

 

Break jumps out of the entire loop. continue stops this loop.

7. Define the function to indent every line of code using def

Def test (a, B): # define the function print (a, B) test (1, 2) # Use the Function

A, B is the row parameter 1, 2 is the real Parameter

 

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.