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

本文介绍了Python编程的基本概念,包括变量定义、字符串操作、算术运算及简单的输出指令等,并通过实例展示了如何进行数值计算和字符串拼接。
# 三个基本要素 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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/220205/viewspace-2065405/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值