2020_9_22_markdown syntax + python language foundation and variables

Day 1

Markdown syntax:

1. Title-Add 1-6 # at the beginning of a line of ordinary text (ctrl+/toggle editing status)

2. Code quotation-put the text corresponding to the code between the beginning and the end of the three backquotes (```)

print('hello world')

3. General reference

1) Part of the text is between two backticks

1234

2) Add one or more> at the beginning of the text

hello

hi

4. Picture- ![]()

5. Hyperlink- [可点击文字](跳转地址)

Click on Baidu to find

6. List

1) Ordered list-add numbers and spaces before the text

  1. q
  2. s

2) Unordered list-before the text + or-press the table key to generate the next level

  • r
  • g
    • f
      • b

7. Form-|-|–|—|

Day 2

Python language foundation and variables

1.hello world

2. Python basic syntax

1) Statements-one statement occupies a line, no need to write a semicolon after the end of a line; if you want to write multiple statements on a line, you must use a semicolon to separate the statements

2) Comment

a. Single line comment-add # at the beginning (ctrl+/ can add and cancel comments)
b. Multi-line comments-'''''' or """ """

3) Indentation-Python uses colons and indentation to generate code blocks, spaces and tabs indicate indentation

4) Identifiers-name variables, functions, and classes

5) Keywords-Identifiers with special functions or meanings are keywords ['False','None','True','and','as','assert','async','await', ' break','class','continue','def','del','elif','else','except','finally','for','from','global','if' ,'import','in','is','lambda','nonlocal','not','or','pass','raise','return','try','while', ' with','yield']

6) Common data and data types

6.1) Data
a. Digital data
b. Text data
c. Boolean data
6.2) Data type
a. Integer-int
b. Floating point-float
c. String-str
d. Boolean-bool

7).type function-type (data)-get data corresponding type

3. Input and output functions

1) Output function-print

2) Parameter end

print(‘abc’.end=’’)

print(‘fgh’)

3) Parameter sep-control the interval between multiple data printed by print at the same time (the default is a space)

print(1,2,3,sep=’’)

4) Input function-int

4. Variables-used to save data

4.1 Define variables-variable name = data

4.2 Use Variables-Use the data saved in variables

4.3 Modify variables-re-assign variables, the same variable can store different types of data

4.4 Define multiple variables at the same time

4.4.1 Define multiple variables at the same time and assign the same value

a=b=c=1

4.4.2 Define multiple variables at the same time and assign different values

a, b, c = 1, 2, 3

4.5 Exercise: The values ​​of the two variables m and n are 10 and 20 respectively, write code to exchange the values ​​of m and n

method one:

m, n = 10, 20

m, n = n, m

Method Two:

m, n = 10, 20

k = m

m = n

n = k

4.6 Python can assign 9999**9999, but C and JAVA cannot

5. The principle of defining variables and assigning values ​​to variables

5.1 When Python defines variables, it first opens up a suitable size of memory space according to the size of the data, then stores the data in the corresponding memory space, and finally binds the variable and the memory space. When re-assigning a variable, it is to open a new memory to store new data. The size of the new memory space is the same as the new data, and the variable is bound to the new memory space.

5.2 What is actually stored in the variables in python is actually the address of the data in the memory

5.3 Get the address of a variable-id (variable)

5.4 Assign a value with one variable to another variable, in fact the assigned address

5.5

list1 = [1, 2, 3, 4]
list2 = list1    # 赋的是地址
print(list1, list2)

list1.append(100)
print(list1, list2)

5.6 Coding specifications

5.6.1. A space is required between the comment content and #
5.6.2. Spaces are required on both sides of the assignment symbol
5.6.3. A space is required after the comma

Guess you like

Origin blog.csdn.net/xdhmanan/article/details/108745877