为了账号安全,请及时绑定邮箱和手机立即绑定
a = 'python' , a为True。print('hello,', a or 'world') 或计算中字串符结果是False,所以显示结果为a=‘python’。b = '',b是空值,print('hello,', b or 'world'),或计算中不显示空值,是以结果显示为world。
def sub_sum(L):
sum1=0
sum2=0
for a in L:
if a%2==0:
sum1=sum1+a
else:
sum2=sum2+a
return sum1,sum2
L=[1,2,3,4]
b=sub_sum(L)
print(b)
hello='Hello'
space=' '
world='World'
print(hello+space+world)
age = 19
if age>=18:
print('adult')

print(age)

最赞回答 / the_tops
template = '{0}, {1}'result = template.format('WorldLife is short', 'you need Python .')print(result)template = '{w}, {c}'World = 'WorldLife is short'you = 'you need Python .'result1 = template.format(w = World, c = you)print(result1)

最赞回答 / 尘羽385826
哦,我知道原因了,因为我a的代码中,是用了两个单引号'',而不是一个"双引号,所以字符无效
浮点数是啥意思
第一个浮点数,第二个是整数,第三个是二进制
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

最新回答 / Lanjier119
a='Hello'b=' 'c='World'd='!'print(a+b+c+d)
>>> s='AABCDEFGHHIJ'
>>> abcdefgh=s[1:9]
>>> print(abcdefgh)
ABCDEFGH
>>> s1='这是一句中英文混合的Python字符串:Hello World!'
>>> print(s1)
这是一句中英文混合的Python字符串:Hello World!
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消