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

a='Life is short,{c}'
b='you need Python.'
result=a.format(c=b)
print(result)
# Enter a code
a=r''' '\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer. '''
print(a)
我觉得没必要判断奇偶啊,直接num=0 每次加2就可以了。
num = 0
sum = 0
while True:
if num > 1000:
break
sum = sum + num
num = num + 2
print(sum)

最新回答 / LVXC
第五行90后面的冒号你用成了中文的,应该改成英文的冒号。
#..........
ab= ' {}'
b =ab.format('Life is short,you need python')
print(b)
N = 'Life is {0},you need {1}'
b2= N.format('short','python')
print(b2)
N2 ='Life is {w},you need {y}'
short ='short'
python ='pythin'
b3=N2.format(w=short,y=python)
print(b3)
moban='{a} {b} {c},{d} {e} {f}.'
a1='Life'
b1='is'
c1='short'
d1='you'
e1='need'
f1='Python'
result=moban.format(a=a1,b=b1,c=c1,d=d1,e=e1,f=f1)
print(result)
num=0
L = ['Alice', 66, 'Bob', True, 'False', 100]
while num<=5:
num=num+1
if num%2==0:
continue

print(L[num])
L=[75,92,59,68,99]
sum=0
for i in range(len(L)):
sum=L[i]+sum
print(sum/len(L))
L = [95.5, 85, 59, 66, 72]
a=0
b=0
c=0

for ch in L:
temp=ch

if ch>a :
a=temp
elif ch>b:
b=temp
elif ch>c:
c=temp
print(a,b,c)
from itertools import permutations
s1 = 'ABC'
s2 = '123'
s3 = 'xyz'
for ss1 in s1:
for ss2 in s2:
for ss3 in s3:
for s in permutations([ss1, ss2, ss3]):
print(''.join(s))

最新回答 / 精慕门0091131
看题目, 通过for循环访问列表每一个元素的方式,我们称为迭代。
L = []
for n in range(1, 101):
L.append(n*n)
print(sum(L))
num1=3.14
num2=1.57
result=num1*num2
print(round(result,2))
print('special string:'+"',"+'",'+'\,'+'\\\,'+'\\n,'+'\\t')
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消