为了账号安全,请及时绑定邮箱和手机立即绑定
template = 'Life is {x},you need {y}'
x='short'
y='Python'
result=template.format(x = x,y = y)
print(result)

template = 'Life is {1},you need {0}'
result1 = template.format('Python','short')
print(result1)
print(r''' "To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
s = 0
a = 0
while True:
if s >= 1000:
break
s = s + 2
a = a + s
print(a)
更简单
def sub_sum(l):
x = []
y = []
for i in range(len(l)):
if i % 2 ==0:
x.append(l[i]*l[i])
else:
y.append(l[i]*l[i])
print("奇数位平方和为{0},\n偶数位平方和为{1}".format(sum(x),sum(y)))
sub_sum([1,2,3,4])
def square_of_sum(l):

for i in l:
eg = []
eg.append(i * i)
sum(eg)
print(sum(eg))


square_of_sum([1, 3, 5, 7])

最新回答 / 暗夜子爵
<...code...>d = {    'Alice': 45,    'Bob': 60,    'Candy': 75,    'David': 86,    'Ellena': 49,    'Gaven': 86}AA = ('Alice', 'Bob', 'Candy', 'Mimi', 'David')for i in AA:    print(i + ":" + str(d.get(i)))
names=['Alice','Bob','David','Ellena']
news=['Zero','Phoebe','Gen']
news.sort()
print(news)
count=len(names)
for n in news:
names.insert(count,n)
count+=1
print(names)

最新回答 / qq_慕慕3296986
官网安装Python环境 然后安装pycharm 编程
这哪是第一名,第二名和第三名,明明是第一名,第二名,和最后一名
是98吧,类似数学取交集
楼下什么意思
print(r"""'To be, or not to be:
that is the question.
Whether it's nobler in the mind to suffer.'""")
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消