Basic knowledge
First, Python is an interpreted language, that is, the program does not need to compile, at run time to translate into machine language, every execution once to translate once, so less efficient
Ii. explanatory language and compiled language
Compiled languages
is to first write the program into a computer language and then execute, is called a compile everywhere, such as C, C + + is a compiled language, the language is characterized by the speed of running, but need to pre-compile the program can be.
Interpreted language
is the program at the time of operation, through an interpreter, the code is translated into a computer language and then run, that is, you write the code to run directly, such as Python, Shell, Ruby, Java, Perl, etc. are
Interpreted language, of course, such a language because the principle is not the same, the execution speed is not compiled language fast.
Python applications:
Background service development, data mining, data analysis, artificial intelligence, automated operations, automated testing
Single-line Comment: # (shortcut key ctrl+/)
Multiline Comment: Double three quotes "" "Single Triple Quote '"
Variable: = Used to assign a value
1 ) variable name rule: ( see name and meaning )
1. Any combination of letters, numbers, underscores 2. The first number must not be the number 3. Variable name it's better to be famous. 4. You cannot use keywords (such as) as variable names
2 ) variable assignment
A variable assignment in Python does not need to specify a data type and can be defined directly.
The equals sign (=) is used to assign a value to a variable. The left side of the equals operator is a variable name, and the right side of the equals operator is the value stored in the variable.
Each variable must be assigned before it is used, and the variable will not be created until the variable is assigned.
The equal sign is followed by either single or double quotation marks, which is a character string character type, an integer after the equal sign, or an int integer, or a float after the equal sign
PS: all English symbols ctrl+d quick copy Line
Variable type (int, float, str)
Conditional judgment (if condition is judged to be added: Colon )
Single condition judgment Multi-Conditional judgment
Here is a condition two ways of writing (judging gender)
Little Practice
Cycle
While loop
While loop writing guessing games
While corresponding to an else, the loop executes after the normal end.
For loop
Print three times Hello World
String formatting
Little Practice Login Program
Username
passwd
Let the user enter the account number and password
If user name and password input correct prompt you xxx, welcome to login, today's date is XXX, program end
Error, Prompt account/password error
The maximum input three times, if the input 3 times is wrong, the error is too many failures.
Need to determine the input is empty
Getting Started with Python