age = 19
if age >= 18:
temp = 'adult {}'
print(temp.format(age))
if age >= 18:
temp = 'adult {}'
print(temp.format(age))
2025-07-21
# Enter a code
template = 'Life is {0}, {1} {2} {3}'
template1 = 'Life is {a},{b},{c} {d}'
print(template.format("short","you","need","python"))
aa='short'
bb = 'you'
cc = 'need'
dd = 'python'
print(template1.format(a=aa,b=bb,c=cc,d=dd))
template = 'Life is {0}, {1} {2} {3}'
template1 = 'Life is {a},{b},{c} {d}'
print(template.format("short","you","need","python"))
aa='short'
bb = 'you'
cc = 'need'
dd = 'python'
print(template1.format(a=aa,b=bb,c=cc,d=dd))
2025-07-21
print(r'''To be, or not to be: that is the question.Whether it's nobler in the mind to suffer.''')
2025-07-21
Python遍历dict
通过直接print(d),我们打印出来的是完整的一个dict;有时候,我们需要把dict中m(满足)一定条件的元素打印出来
通过直接print(d),我们打印出来的是完整的一个dict;有时候,我们需要把dict中m(满足)一定条件的元素打印出来
2025-07-18
def sub_sum(n):
if n <= 0:
return 0
return n+sub_sum(n-1)
n=100
print(sub_sum(n))
if n <= 0:
return 0
return n+sub_sum(n-1)
n=100
print(sub_sum(n))
2025-07-06
最新回答 / 不吃香菜吖
d = { 'Alice': 45, 'Bob': 60, 'Candy': 75, 'David': 86, 'Ellena': 49}# name = input('to del whose score:')name = 'Alice'try: d.pop(name) print(name + ' deleted')except: print(name + ' none')
2025-05-29
# 方法一
template1 = 'Life is {0}, you need {1}'
print(template1.format('short', 'Python'))
# 方法二
template2 = 'Lift is {p1}, you need {p2}'
print(template2.format(p1 = 'short', p2 = 'Python'))
template1 = 'Life is {0}, you need {1}'
print(template1.format('short', 'Python'))
# 方法二
template2 = 'Lift is {p1}, you need {p2}'
print(template2.format(p1 = 'short', p2 = 'Python'))
2025-05-19
最新回答 / 幸福的棉花糖
在交互式环境中,执行上述代码后,会直接输出 3.14,而不需要显式调用 print()。这是因为 Python 的交互式环境会将表达式的计算结果作为返回值自动显示。然而,在脚本文件(如 .py 文件)中运行相同的代码时,如果没有使用 print(),则不会输出任何内容,因为脚本模式不会自动打印表达式的返回值。因此,在脚本中需要显式使用 print() 来显示结果
2025-04-29