为了账号安全,请及时绑定邮箱和手机立即绑定
L=[75,92,59,68,99]
sum=0.0
for ch in L:
sum=sum+ch
print(sum/5)
age=8
if age>=18:
print('adult')
elif age>=6:
print('teenager')
elif age>=3:
print('kid')
else:
print('baby')
age=8
if age>=18:
print('adult')
elif age>=6:
print('teenager')
elif age>=3:
print('kid')
else:
print('baby')
a=19
if a>18:
print('adult')
else:
print('teenage')
>>> dongdongqiang=19
>>> if dongdongqiang>18:
... print('adult')
...
adult
>>> s='AABCDEFGHHIJ'
>>> abcdefgh=s[1:9]
>>> print(abcdefgh)
ABCDEFGH
>>> s1='这是一句中英文混合的Python字符串:Hello World!'
>>> print(s1)
这是一句中英文混合的Python字符串:Hello World!
T = ((1+2), ((1+2),), ('a'+'b'), (1, ), (1,2,3,4,5))
for a in T:
print(type(a))
结果:
<class 'int'>
<class 'tuple'>
<class 'str'>
<class 'tuple'>
<class 'tuple'>
所以是3个
>>> template='Life is short,you need {}'
>>> a='Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
或者
>>> template='Life is short,{}'
>>> a='you need Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
>>> template='Life is short,you need {}'
>>> a='Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python

或者
>>> template='Life is short,{}'
>>> a='you need Python'
>>> result=template.format(a)
>>> print(result)
Life is short,you need Python
可以参考一下我的:
num=0
sum=0
while num<=1000:
if num%2<>0:
num=num+1
continue
sum=sum+num
num=num+1
print(sum,num)
d = {
'Alice': [45],
'Bob': [60],
'Candy': [75],
};
socre_a=[50,61,66];
socre_b=[80,61,66];
socre_c=[88,75,90];
num=0;
while num<3:
d['Alice'].append(socre_a[num]);
d['Bob'].append(socre_b[num]);
d['Candy'].append(socre_c[num]);
num+=1;
print(d);
或'special string:\',",\\,\\\,\\n,\\t'
>>> s='special string:\',",\\,\\\,\\n,\\t'
>>> print(s)
special string:',",\,\\,\n,\t
#coding:UTF-8
num = 1
a=0
sum=0
while True:
if a>1000:
break
if a%2==1:
sum=sum+0
else:
sum=sum+a
a=a+2
print(sum)
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消