Introduction to Python & Looping statements1.Python Introduction
The founder of Python for Kat · Van Rossum (Guido van Rossum). During the Christmas of 1989, Guido began writing the Python language editor. Python's name is from Guido's beloved TV drama Monty Python's Flying Circus. He hopes that the new language, called Python, will fit his ideals: create a language that is versatile, easy to learn, and extensible, between C and Shell.
2. Current Python's main application areas
Web development, network programming, crawler, cloud computing, artificial intelligence, automated operation and maintenance, scientific computing, game development, etc...
3. Current Python rankings
Address (https://www.tiobe.com/tiobe-index/)
4.Python Installation
Open official website (https://www.python.org/downloads/windows) direct download of Windows system
5. First Python program
After the program is installed, press the [window] key +r key to open the run, then enter CMD into the dos window, enter Python, if you enter the interactive environment to represent the successful installation, otherwise the environment variable is not good.
Print ("HelloWorld")
6. Variables, constants 6.1. The definition of a variable:
1. Variables can only be any combination of letters, numbers, or underscores
2. The first character of a variable cannot be a number
3. Keywords cannot be declared as variables [' and ', ' as ', ' break ', ' for ', ' Assert ', ' class ', ' if ', ' print ', ' pass ', ' else ', ' yield ', ' return ', ' on ', ' form ' Etc.....]
6.2. How to define:
1. Underline Age_of_oldboy = 58
6.3. Definition of constants:
1. Constants are constant quantities, such as π= 3.15.592653 ... or a quantity that does not change in the program's operation.
7. Program Interaction & Indentation 7.1 Read user input:
Name = input ("what isyour name? ") " )print("" + name)
7.2 Indent Format:
Number = 1if number > 0: print(number)else: Print(-number)
8. Comments & Header File Encoding 8.1 single-line comment: #被注释的内容
# Xiaoqian = 1
More than 8.2 lines of comment content: ' The content of the comment '
"' Xaioqianxiaowangxiaobai '
8.3 Header file Encoding:
# _*_coding:utf-8_*_
9.if...else ... Statement
' Xiaoqian ' =if'xiaoqian' and age==20: # determine if variable is consistent Print(" Welcome entry ") # and output welcome message else: print(" name is inconsistent with age ")
10.for ... Statement
for inch # Loops 0 to 9 Print (i)
11.whlie ... Statement
while True: Print ("xaioqian"# Infinite loop Xiaoqian
Number = 0 while True: print("xiaoqian", Number) +=1 if number = =: print(" Loop End ") break
Operation Result:
Python Full stack development Day1