1. Input method Inputs ()
Wait for the user to enter data and get the data (name is the input string) after return
Name=input (' pleaseinput your name:')print('Hi, ', name)
To run the code effect:
2, the wording of the note: #开头
#the statement at the beginning is a comment, and the comment is visible to the person and can be anything, and the interpreter ignores the comment.
When the statement ends with a colon: The indented statement is treated as a block of code, with no specified indentation being a few spaces, but the convention is commonly known as 4 spaces.
# Note:firse Code Demo # Print absolute value of an integer:a=100if a >=0: print(a) else: Print
The output is:
3. Data type
integers, such as 20,-100
Floating-point numbers, such as 1.2323, use scientific notation for large numbers, and e instead of 10, for example, 1.23x109 is 1.23e9.
strings, such as ' abc ', ' Hello World ',
Escape, use \ To transfer single and double quotes, \ \ escape \,\n, \ t tab,
Do not escape, R ' \xxx\xxx ' means ' \xxx\xxx ' without escaping
Multiple lines, with ' xxxxxxx ' for Multiline content
Print ('line1line2line3')
Output to
Boolean value, only 2 values, true and false, note case, Python is case sensitive. He can use and, Or,not, to perform operations.
NULL, none, cannot be understood as 0, because 0 is meaningful, and none is a special null value.
constants, usually denoted by a variable name in all capitals, such as the notation of π: pi=3.14159265359
There are also dictionaries, lists, and custom data types.
4. Variables
The variable name must be a combination of uppercase and lowercase English, numeric, and numeric _ , and cannot begin with a number.
In Python, an equal sign = is an assignment statement that assigns any data type to a variable, the same variable can be repeatedly assigned, and can be a variable of different types, such as
# A is an integer Print 'ABC'# a changed to string print(a)
In addition, there is a division that is // called a floor divide, where a division of two integers is still an integer:
>>> 10//33
python--Basic rules of writing