a=2
at=0
while a<=1000:
if a == 1000:
break;
at+=a
a=a+2
print(at)
at=0
while a<=1000:
if a == 1000:
break;
at+=a
a=a+2
print(at)
2023-07-26
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)
A = 'you need Python'
result = template.format(A)
print(result)
template = 'Life is short,{}'
result = template.format('you need Python')
print(result)
2023-07-26
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)
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)
2023-07-18
# 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 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])
2023-07-16
def greet(x=None):
if x != None:
print("Hello,World")
else:
print('hello')
s1=greet(22)
print(s1)
if x != None:
print("Hello,World")
else:
print('hello')
s1=greet(22)
print(s1)
2023-07-15
可以这样就行了
def fact(n):
if n==1:
return 1
return n + fact(n - 1)
s2 =fact(100)
print(s2)
def fact(n):
if n==1:
return 1
return n + fact(n - 1)
s2 =fact(100)
print(s2)
2023-07-15
>>> 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.
>>>
... 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.
>>>
2023-07-14