與小卡特一起學python 第2章 記住記憶體和變數 2-1練習

yarking207發表於2016-03-28
# 三個基本要素 input process output
teacher = "Mr.Morton" #variable name variable name 注意區分大小寫
print(teacher) #Teacher and teacher 變數名不能出現空格,必須是字母或者一個下劃線字元開頭
print("53+28")
print("53+28=",53+28)
First = 5
Second =3
print (First + Second)
Third = First + Second
print (Third)  #數值的運算
first="5"
second ="3"
print(first + second) #字元的拼接concatenation
teacher ="Mr.Morton"
print(teacher)
teacher ='Mr.Morton' #""和''是一樣,但要成對出現
print(teacher)
print("cat" +"dog")
long_string ="""Sing a song of sixpence,a pocket full of rye,
Four and twenty blackbirds baked in pie.
When the pie was opened the birds began to sing.
Wasn't that a darnty dish to set before the king?"""
long_string1 ='''Sing a song of sixpence,a pocket full of rye,
Four and twenty blackbirds baked in pie.
When the pie was opened the birds began to sing.
Wasn't that a darnty dish to set before the king?'''
print(long_string) #長字串""""""或者''' ''' triple-quoted string
print(long_string1)
print(teacher)
teacher='Mr.Smith'
print(teacher) #變數的可變性,多變
Score = 7
Score = Score
Score = Score + 1
print(Score)
t='Mr.Morton' #變數名稱要使用容易記的變數名。
x1796vc47blahblah='Mr.Morton'#變數名太長,暈了,一般人記不住
print(t)
print(x1796vc47blahblah)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/220205/viewspace-2065405/,如需轉載,請註明出處,否則將追究法律責任。

相關文章