ITPub博客

首页 > 应用开发 > IT综合 > 与小卡特一起学python 第2章 记住内存和变量 2-1练习

与小卡特一起学python 第2章 记住内存和变量 2-1练习

原创 IT综合 作者:yarking207 时间:2016-03-28 19:15:45 0 删除 编辑
# 三个基本要素 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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-08-03

  • 博文量
    65
  • 访问量
    78774