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)
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)
2022-11-25
print(r''' "To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.''')
Whether it's nobler in the mind to suffer.''')
2022-11-24
s = 0
a = 0
while True:
if s >= 1000:
break
s = s + 2
a = a + s
print(a)
更简单
a = 0
while True:
if s >= 1000:
break
s = s + 2
a = a + s
print(a)
更简单
2022-11-24
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])
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])
2022-11-22
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])
for i in l:
eg = []
eg.append(i * i)
sum(eg)
print(sum(eg))
square_of_sum([1, 3, 5, 7])
2022-11-22
最新回答 / 暗夜子爵
<...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)))
2022-11-21
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)
news=['Zero','Phoebe','Gen']
news.sort()
print(news)
count=len(names)
for n in news:
names.insert(count,n)
count+=1
print(names)
2022-11-19
print(r"""'To be, or not to be:
that is the question.
Whether it's nobler in the mind to suffer.'""")
that is the question.
Whether it's nobler in the mind to suffer.'""")
2022-11-01