L = ['Alice', 66, 'Bob', True, 'False', 100]
num = 1
for c in L:
if num % 2 == 0:
print(c)
num += 1
num = 1
for c in L:
if num % 2 == 0:
print(c)
num += 1
2025-07-22
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},,{c} nhkv1sx5v02o'
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},,{c} nhkv1sx5v02o'
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