A. Hello World program
Create a python file in Pycharm
Run results
Rules for variable definitions:
- Variable names can only be any combination of letters, numbers, or underscores
- The first character of a variable name cannot be a number
- The following keywords cannot be declared as variable names
[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']
Assigning values to variables
Note: in Python3. UFT-8 encoding is supported directly in X without the need to start labeling in the file. In addition, Chinese variables are supported in Python3
Comments:
When line comment: # is commented content
Multi-line Comment: ' Annotated content '
About single and double quotation marks:
Single and double quotes in Python are not removed, quotation marks can be applied in quotation marks without causing errors
About three quotes:
13 quotation marks for multi-line comments
23 quotation marks can represent multi-line content, formatted output of multi-line content
1.
2.
3.
Note: Not recommended method Three, method three need to strictly remember the variable order
User input:
Note: input is a string type and must be cast with an int () If you need to reshape the value. You can also cast to a string using str ().
If you do not want to enter the password visible, you can use the Getpass method in the Getpass module:
SELECT statement:
If...else
If...elif...else
Loop structure:
1.for Loop:
2while Loop:
Python (i)