为了账号安全,请及时绑定邮箱和手机立即绑定

最赞回答 / 慕少0598786
因为你写错了a=0b=0while True:    if a > 1000:        break    if a % 2 == 0:        b=b+a    a=a+1print(b) 这样才对
l=[75,92,59,68,99]
sum=0
a=0
for i in l:
if i is not None:
sum=eval("sum + i")
a=eval("a+1")

else:
break
b=eval("sum/a")
print("总值是:",sum)
print("一共有",a,"个值")
print("平均值为:",b)
a=int(input("请输入您的年龄:"))
if a >=18:
print("adult")
elif a <18 and a > 6:
print("teenager")
elif a >=3 and a<=6:
print("kid")
else:
print("baby")
你这节课超纲了吧。。。。。

最新回答 / weixin_慕婉清0361474
你这if的判断条件,跳过的是偶数

已采纳回答 / weibo_東匚酆筤_0
可以记一下,后续再逻辑开发的过程中会经常出现,当然不需要死记硬背,以后用的多了自然而然的也就记住了
template = '{}'
result1 = template.format('Life is short, you need Python')
print(result1)

temp = 'Life is short, {}'
result2 = temp.format('you need Python')
print(result2)

tmp = "{0} {1} {2}, {3} {4} {5}"
result3 = tmp.format('Life','is','short','you','need','Python')
print(result3)
print(r"""'\"To be, or not to be\": that is the question.\nWheth
er it\'s nobler in the mind to suffer.'""")
print("special string: '")
print("\"")
print("\\")
print("\\\\")
print("\\n")
print("\\t")
python3.x中cmp函数去掉了,如果需要实现比较功能,那么可引入operator 模块 import operator
print(operator.lt(3,4) ==>True

已采纳回答 / liakin
直接用5 / 3的话会被认为是整数类型的运算,最后结果会输出整数类型,用5.0 / 3.0即可
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name1 = L.pop(2)
name2 = L.pop(2)
print(L)

最新回答 / 天堂没有神
template1 = 'Life is {},'template2 = 'you need {a}'k423 = 'python'print(template1.format('short'),template2.format(a=k423))这样就可以

最新回答 / qq_慕工程7590247
result = template.format(w=w , c=c , b=b, i=i )这一行要这样写,w=w,第一个w指template = 'Hello {w}, Hello {c}, Hello {b}, Hello {i}.'这里定义的形参,第二个指 w = 'World'这里定义的实参学了函数就知道了这个报错就是编译器找不到你定义的实参
age = 19 # 咚咚呛的年龄是19岁
if age >= 18:
print("adult")
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消