为了账号安全,请及时绑定邮箱和手机立即绑定
ge = 19
if age > 18:
print('adult',age)
print ('ddq = {}'.format (age))
print ('adult')
num = num + 1什么意思
template = 'life is {0}, you need {1},'
result = template.format('short', 'python')
print(result)

template = 'life is {s}, you need {p}, '
s = 'short'
p = 'python'
result = template.format(s ='short', p = 'python')
print (result)
# Enter a code
template = 'life is short, {}'
Y = 'you need python'
result = template.format(Y)
print(result)
#for循环序写法
def sum100(s):
num = 0
for a in range(1,s+1):
num+= a
return num
print (sum100(5))
# Enter a code
T = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1,2,3,4,5))
num = 0
for t in T:
if isinstance(t,tuple):
num += 1
print(num)
T = (1, 'CH', (3, 4))
这样吧 把list[3,4]变成tuple(3,4)就不可变了
T = (100, 69, 29, 100, 72, 99, 98, 100, 75, 100, 100, 42, 88, 100)
print(T.count(100))
# Enter a code
num1 = 3.14
num2 = 1.57
result = num1 * num2 * 2
print(result) # ==>
# Enter a code
n=0
s=0
while True:
n+=1
if n>1000:
break
if n%2==1:
continue
s+=n
print s
n=0
s=0
print n
while True:
if n>1000:
break
elif n%2==0:
s+=n
n+=1
print s
定义 template = 'Hello {}' ,如果Hello替换为中文会报错
i = 0
sum = 0
while True:
if i <= 1000:
sum += i
i += 2
else:
break
print(sum)
计算的结果分别是数字和字符串,不是tuple。
本身set中的元素就不可以重复,S. update(L) print(S)出来的就是重复的是删除的,不重复的添加到了set中。L是list 删除元素是pop(),不能用rwmove
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消