first, the basic grammar
1. Line and indent
In Python, you do not use parentheses to represent code class and function definition blocks or process controls.
Code blocks are indented by rows , and the number of indents is variable, but all statements in the block must be indented the same amount.
As shown below:
A =if a >= 0: print(a)else: Print(-a)
Similarly, it is recommended to have a tab set to 4 spaces (Editor->code sytle)
2. Notes
After the "#" sign and to the physical line are part of the comment, the Python interpreter ignores them.
# First Comment Print " Hello, python!. "; # Second comment
3. Quotation marks
Python accepts single quotes ('), double quotation marks ("), and three (" or "") references to denote string constants as long as they are the same type of quotation marks that start and end the string.
Sanchong quotes can be used for strings that span multiple lines. For example, all of the following are legal:
' Word ' "This isa sentence. " "" "This isa paragraph. It ismade up of multiple lines and sentences. """
4. Semicolon
Like Scala, semicolons are optional. Generally, you can omit
ii. Types of data
A) Number
b) string
c) List
d) tuples
e) Dictionary
f) Set
You do not need to display the specified variable type when defining a variable in Python, the following is the typical syntax used by variables in Python:
# Basic use (even if Val in Scala is saved, fully automatic type inference)counter = # int = 1000.0 # Floating-point name "John" # string
Python3 Introduction (iii)--python Basic grammar