ctrl + c - Copy / Copy
ctrl + v - Paste
ctrl + / - Add or remove comments
ctrl + x - shear
ctrl + s - preservation
ctrl + z - revoke
ctrl + a - Future generations
1、 notes : Is the part of the code that does not participate in compilation and execution ( The existence of comments will not affect the function of the program )
Single-line comments : Add... Before the notes # ( Shortcut key : ctr + /)
# I'm a line of comments
Multiline comment : Put multiple lines of comment in three quotation marks ( Three double quotes or three single quotes are OK )
""" I am the first 1 Line notes I am the first 2 Line notes I am the first 3 Line notes """
The function of annotation :
a. Annotate the code with , Improve the readability of the code
b. Cancel code function
2、 Lines and indents
1) That's ok
python One line of code , You can end a line without a semicolon , If you have to display multiple statements on one line ,
A semicolon must be added between statements
2) Indent : The space before a statement is called indentation
A statement cannot be preceded by any blank space
3、 Identifiers and keywords
1) identifier - Naming requirements
python Identifier requirements : By letter 、 Numbers or underscores , And numbers don't start
2) keyword - python Some identifiers with special functions or special meanings in , It can't be used for other purposes !
False None True and as assert 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
4、 Common data and data types
1) Digital data : Data used to represent the size of a numeric value , for example : The age of people 、 height
The method of representing digital data in a program : The same way that numbers are represented in Mathematics , And support scientific counting
The type corresponding to the number : Digital data is divided into integer types (int- Integers ) And floating point (float- decimal ) Two kinds of
2) Text data : It is used to represent the data corresponding to text information , for example : full name 、 Address
Representation : The text data must be enclosed in double or single quotation marks ,
type : character string (str)
3) Boolean data : Only True and False Two values ,True Said really 、 sure ;False Said the false 、 no .
(True and False Is the key word )
Representation : direct writing True、False
type : Boolean (bool)
4) Null value :None (None Is the key word )
type :NoneType
5、 Type operation
1) Get data type :type( data ) - Gets the type of the specified data
type(' Hello ')
2) Type conversion : Type name ( data ) - Converts the specified data to the specified type
print(int(3.5))
1、print Is to display the data in the program on the console ( Print ) come out . What is displayed in the console , It must be used in the program
print Printed content
1) Basic usage
a. One print Print a data :print( data )
print('hello')
b. One print Print multiple data at the same time :print( data 1, data 2, data 3, …)
print(10, 20)
2) Advanced usage
a. customized end: print( data 1, data 2,…, end= character string )
By default, there is one print The printed content occupies one line
Printing principle : Program designation print During operation , Will print the data first , The data will be printed after printing end Value (end The default value of is
Line break )
b. customized sep
customized sep It is used to control when printing data at the same time , How data is separated from data , Default is space
1、input function
Variable = input( Enter the prompt message ) - Prompt the user to enter content , And save the input to the variable
age = input(' Please enter your age :')
Write program tips ⽤ User input ⽤ Account name and password , And will lose ⼊ The contents of are saved to different variables .
username = input(' Please enter a user name :')
password = input(' Please input a password :')
send ⽤ One print Output 3 Data ,3 There's data in ⼀ Row display , And use the equal sign (=) separate .
print('10 + 5',20,'hello word',sep='=')
When declaring variables , What are the precautions for variable names ?
a. Is an identifier.
b. It can't be a keyword
c. Know what you know ( When you see the variable name, you know what data is stored in the variable )
d. Do not use the system function name 、 Class name and module name
e. The letters are all lowercase
f. Multiple words are separated by underscores
Please write out Python What are the advantages of language .
Grammar is simple , The cost of learning is low , There are many standard libraries and third libraries , Powerful , Open source code .
Please write out Python often ⻅ Application fields of .
Data analysis 、 Artificial intelligence 、 data mining 、 Reptiles 、 The front-end development .
Write down the questions you have about today's lecture ( Or knowledge points that feel difficult ).
nothing