First, Introduction
Python is created by Guido van Rossum, which is highly portable and extensible to embed, with the disadvantage of being slow to run, not encrypted, and not multithreaded. At present, the main direction of Python is cloud computing, web development, scientific computing, artificial intelligence, system operations, finance, graphics Gui,python is interpreted by the CPython interpreter, translated into machine-recognized language, Python is usually developed using Pycharm.
Second, installation
On the official website www.python.org download python3.5 above installation package for installation, note the path tick (configure environment variables), so that the input Python on the console can display version information, install the python2.7 version sometimes the environment variable will be unsuccessful, when the installation path is copied Pytho N.exe rename it to Python2.exe.
Search online for download pycharm and Notepad installation
Third, Hello World
1, on the console directly code, console input Python after the cursor after the code on the line
Print ("helloWorld")
It is important to note that this print is not followed by a semicolon.
2, write using Notepad or Notepad, as long as the file type is. PY can be
On the console, go to the path where the Python code is located, and enter the command Python file name. py
Iv. Types of data
Variables: Variables are composed of numbers, letters, underscores, starting with letters, using a camel or an underscore, hump: capitalize each word except the first letter, such as Pythontest, underline: Each word is separated by an underscore such as Python_test
Constants: There is no absolute constant in Python, it is only the convention that the variable name is capitalized as a constant, and no longer changes its value
Note: Use the # comment line to annotate multiple lines with ' ' '
Integer: int string: str string using single quotation mark ' or double quotation mark ' or three single quotation mark ' "' or three double quotation mark" "" "", where three single quotation marks and three double quotation marks can be wrapped.
Boolean value (BOOL): Only True (True) False (false) Note spelling
Convert a string to an integer type
A="b" ="C"print(A +b) Print(int (a) +int (b))
V. Statements
1. Interactive statements
Enter input ("prompt statement")
Output print ("Output content")
A=input (" Please enter a value ")print(int (a) +10)
It is important to note that input gets a string of inputs, and the type of a variable can be used to
a=10B="123"type (a) type (b)
2. If statement
A=8if a>10: print("a>10")elif A>5: print("a>5")Else : Print ("a<5")
Note that indentation in Python is important, if the code area should be indented with a TAB key relative to if, while the same is true, the code indentation is the same as the code is at the same level and there is no nesting.
3. While loop
A=1 while True: if a>10: break if a==3: a=a+1 continue print(a) a=a+1
The break jumps out of the loop and ends the loop, and continue jumps out of the loop in which it is performing the next loop.
Python Learning day01 data type if while