Python mooc?之玩轉(zhuǎn)數(shù)據(jù)
Introductions
Key words
Import keyword?
Print(keyword.kwlist)
賦值語(yǔ)句
1)?不需要顯示聲明师崎,根據(jù)值來(lái)確定類型
2)?以引用的方式賦值
Pythons?數(shù)據(jù)類型
布爾型:僅有兩個(gè)數(shù)值,分別是ture?和false?分別使用1,0儲(chǔ)存
序列類型:
運(yùn)算順序
算術(shù)運(yùn)算?
power > positive or negative value > multiply or divide > exact division> mode > plus or minus?
比較運(yùn)算
1)?數(shù)值比較按大小進(jìn)行比較
2)?字符串按照ascii?碼值大小比較
邏輯運(yùn)算
-not /and /or. Have the first priorities?
The overall priorities(calculation) of calculation
Module, packages, library?
Module :
Import modulename ( import single module)
Import modulename1, modulename2, ……(import multiple modules)
Or?
From module1 import moduleElement?
Package?
One package consists a large numbers of modules?
Library?
One library consists of lots of packages?
Module 1
條件
If?語(yǔ)句
Sentence:
If expressions: ( expression means the judgement condition )
?Expre_ture_suite ( this means the actions need to carry out when the satisfy the condition)
e.g?
if sd1==sd2
?print(“the square’s are is “, sd1*sd2)
else
if expression:
?expr_true_suite
else:
?expr_ture_suite
e.g?
sd1=int(input(“the first side:”))
sd2=int(input(“the second side:”))
if sd1==sd2:
?print(“ the sqaure’s area is “, sd1*sd2)
else:
?print(“the rectangle’s area is”, sd1*sd2)
elif (multiple condition, multiple assumptions)
sentences :
if expression:
?expr_true_suite
elif expression2:
?expre2_ture_suite?
elif expressionN?:
?exprN_ture_suite
else?:
?none_of_the_above_s (when the value cannot satisfy any condition above, run this sentence)
e.g?
條件嵌套 (?the sequence of running conditional sentence)
e.g?
range () [function]
Range(start, end, step)
Not indicate the start, it will be automatically stars from 0
Not indicate the step, it will be automatically be 1
NB: the list of numbers do not include the end value, but it include the stared number?
e.g?
range(1,6, 1)
[1,2,3,4,5]
Cycle?
While?
While expression:
?Suite_to_repeat
This cycle also can be understand as not-satisfy-end cycle, which means when the value not longer satisfy expression, this cycle stop.
e.g?
sumA=0
j=1
while j<10:
?sumA+=j
?j+=1?
sumA
?
for?
for iter_var in iterable_object:
?suite_to_repeat
The break, continue and else in the cycle?
Break?
Break terminate the cycle, and turn to run the next sentence?
e.g?