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

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

最新回答 / 送东野
根据短路运算原理,True or True进行运算时,在看到第一个True时就可以确定结果是True,不需要关注后面参与运算的是True还是False,所以只输出第一个True。
template='Life is {},you need {}'
result=template.format('short','python')
print(result)


template='Life is {s},you need {p}'
short='short'
python='python'
result=template.format(s=short,p=python)
print(result)
# Enter a code
def classmate(**kwargs):
for i in range(0,len(kwargs.get('names'))):
print('{} ,{} ,{}'.format(kwargs.get('names')[i],kwargs.get('gender')[i],kwargs.get('age')[i]))
classmate(names = ['Alice', 'Bob', 'Candy'], gender = ['girl', 'boy', 'girl'], age = [16, 17, 15])
def greet(x=None):
if x != None:
print("Hello,World")
else:
print('hello')



s1=greet(22)
print(s1)
可以这样就行了
def fact(n):
if n==1:
return 1
return n + fact(n - 1)

s2 =fact(100)
print(s2)

最新回答 / 慕少1536510
shunyi=template=result = template.format(=,=,=,=shunyi,=)
(result)
>>> print(r'''"To be,or not to be":that is the question.
... Whether it's nobler in the mind to suffer.''')
"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.
>>>
s='special string:(该重复符号了,用\隔开)\',",(又该重复\符号了)\\(表示\本身),(又和\\重复了)\\\\(两个本身),(又重复\)\\n,\\t'
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
for intem in s2:
if intem in s1:
s1.isdisjoint("")
else:
print(intem)
正解:
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])

n = 0
for a in L:
if a in S:
S.remove(a)
L.pop(n)

n += 1

S.update(L)
print(S)

最新回答 / 慕神1423959
应该用isinstance(listLorLtuple, list):判断类型
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for i in range(len(L)):
if L[i] in S:
S.remove(L[i])
else:
S.add(L[i])
print(S)
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for i in range(len(L)):
if L[i] in S:
S.remove(L[i])
print(S)

已采纳回答 / Danny_L
def my_sumA(a):    cc = 100    s=1                 while a < cc:        a += 1        s=s+a    return sprint(my_sumA(1))
课程须知
如果您了解程序设计的基本概念,会简单使用命令行,了解中学数学函数的概念,那么对课程学习会有很大的帮助,让您学起来得心应手,快速进入Python世界。
老师告诉你能学到什么?
通过本课程的学习,您将学会搭建基本的Python开发环境,以函数为基础编写完整的Python代码,熟练掌握Python的基本数据类型以及list和dict的操作,灵活使用流程控制语句。

微信扫码,参与3人拼团

微信客服

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

帮助反馈 APP下载

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

公众号

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

友情提示:

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

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消