Variable names
1, consists of: numbers, letters, underscores
2, variable names to be meaningful
3, the plurality of words are underlined as user_id
4, python variable names do not show Hump
Claim:
a, can not start with a number
b, can not use the keyword
c, try not to use python built-in functions
String:
1, are referred to as quoted string
2, common marks: '', '', '' '', '' '' '' '' '' "" "" ""
3, support operations: +, *
Value:
1, supports operators: +, -, *, /, ** (index),% (take the remainder) // (taken supplier)
Such as: 3 * 4 = 81
5%3=2
5//3=1
if conditional statement
格式1:<br>if 1==1:
print(“ok”)
else:
print(“error”)
嵌套:
if 1 != 1:
if 2 !=2:
print("1")
else:
print("2")
else:
print("---end---")
1
repeatedly found:
score = input("请输入你的分数:")
if score == "90":
print("优秀")
elif score == "80":
print("良好")
elif score == "70":
print("一般")
elif score == "60":
print("及格")
else:
print("不及格")
Supplementary: pass usage (set up is not executed)
输出1-100的奇数:
n = 0
while n <= 100:
n+=1
if n%2 == 0:
pass
else:
print(n)
print("---end---")
Loop:
infinite loop:
import time
while 1==1:
print("ok",time.time())
I write to you, for everyone to recommend a very wide python learning resource gathering, click to enter , there is a senior programmer before learning to share experiences, study notes, there is a chance of business experience, and for everyone to carefully organize a python zero the basis of the actual project data, daily python to you on the latest technology, prospects, learning to leave a message of small details
Knowledge of the point spread:
Variable name:
1, start with an underscore or lowercase letters, optionally followed, any combination of uppercase and lowercase letters and numbers (but generally begin with an underscore have a special meaning, is not recommended) followed by an underscore
2, is recommended to use the English words having a fixed meaning or abbreviations, such as srv = server, skt = socket, generally naming rule based posix
3, recommended hump writing: big hump used to write the class, such as MyFirstLove, small hump as myFirstLove or posix used to write a variable or function names, both compared to the relatively posix recommended wording, such as: my_first_love
4, to avoid reserved words and keywords, such as class, def, break, for; (print out all keywords METHODOLOGY, import keyword; // first cause the key module print (keyword.kwlist) // Print)
This python on this article on the basis of knowledge on the introduction of a variable name to it, the more variable names python Detailed contents