Getting the basics of Python Python

Getting the basics of Python Python

1, variable

(1) variable is the result of running the intermediate temporary stored in memory for subsequent use Code

Role (2) variable:

Nickname, is on behalf of that content in an address in the memory

a = 123

Variable names assign value

(3) variable naming rules:

(1), variable names consist of letters, numbers, underscores

(2), the variable name can not start with a number

(3), having a variable name to be descriptive

(4), variable names are case-sensitive

(5), prohibit the use of variable names Python keyword

(6), the variable name can not use Chinese and Pinyin (not not be used, too low)

(7), variable names recommended wording:

        ``` 驼峰体:AgeOfOldboy```

         ```下划线:(推荐使用):age_of_oldboy```

Assignment (4) variable

print = 123
print(print)
AgeOfOldboy = 67
age_of_oldboy = 67

aeg1 = 10
__ = 10
as = 10         //错误   不能以Python关键字作为变量名
1a = 'alex'     //错误   变量名不能以数字开头

age = 10000000
age1 = 12
age2 = age
age1,age,age2
a101 = "marry"
a101 = "dabao"
print(a101)

age1 = 20
age2 = 18
age1 = 12
age3 = age2
age2 = 15
print(age1,age2,age3)

2, constant: do not change for a long time

ID=12456654642135

Called a constant variable in all caps

3. Note: The explanation is the content of the comment will not be executed

(1) a single line comment (comment when the line): # annotated content

(2) Multi-line comments: '' 'is the annotation content' '' 'or' '' is the annotation content "" "

5, the user interaction :( input / output)

input () - Input

msg = input("请输入您内容:")
print(int(msg) + 5)

(The input to python3 acquired contents are strings, python2 the input data itself is acquired)

print("hello  Word!")

Guess you like

Origin www.cnblogs.com/caiyongliang/p/11404155.html