# Enter a code
n=1
result = 1
while n<=10:
result *= n
n+=1
print (result)
n=1
result = 1
while n<=10:
result *= n
n+=1
print (result)
2024-01-22
# -*- coding:utf-8 -*-
# Enter a code
age = 19
if age >= 18:
print('adult {}'.format(age))
else:
print("未成年")
# Enter a code
age = 19
if age >= 18:
print('adult {}'.format(age))
else:
print("未成年")
2024-01-22
template = 'Life is {0}, you need {1}'
result = template.format('short',"Python")
print result
template = 'Life is {s}, you need {p}'
longitude='short'
language="Python"
result = template.format(s=longitude,p=language )
print result
result = template.format('short',"Python")
print result
template = 'Life is {s}, you need {p}'
longitude='short'
language="Python"
result = template.format(s=longitude,p=language )
print result
2024-01-22
spstr1,spstr2,spstr3 = '\',\"','\\,\\\\','\\n\\t'
print('special string: ',spstr1,spstr2,spstr3)
print('special string: ',spstr1,spstr2,spstr3)
2024-01-22
agr = 18
if agr < 3:
print('baby')
else:
if agr > 17:
print('adult')
else:
if agr > 7:
print('teenager')
else:
print('kid')
if agr < 3:
print('baby')
else:
if agr > 17:
print('adult')
else:
if agr > 7:
print('teenager')
else:
print('kid')
2024-01-20
num=0
sum=1
while num<=9:
num=num+1
sum=sum*num
print(sum)
sum=1
while num<=9:
num=num+1
sum=sum*num
print(sum)
2024-01-16
>>> print('holo,',b or 'world')
holo, world
>>> print('holo',b or 'world')
holo world
>>> a='python'
>>> print('holo',a or 'world')
holo python
>>> print('holo,',a or 'world')
holo, python
holo, world
>>> print('holo',b or 'world')
holo world
>>> a='python'
>>> print('holo',a or 'world')
holo python
>>> print('holo,',a or 'world')
holo, python
2023-12-30
# Enter a code
def greet(what = 'world'):
print('Hello,{}'.format(what))
def greet(what = 'world'):
print('Hello,{}'.format(what))
2023-12-27
# Enter a code
def func(x):
if isinstance(x, list):
return sum(x)
elif isinstance(x, tuple):
multi = 1
for n in x:
multi *= n
return multi
def func(x):
if isinstance(x, list):
return sum(x)
elif isinstance(x, tuple):
multi = 1
for n in x:
multi *= n
return multi
2023-12-27
# coding=utf-8
def sum_func(n):
if n <= 1:
return 1
else:
return (n + sum_func(n-1))
def sum_for():
total = 0
for n in range(1, 101):
total += n
return total
def sum_func(n):
if n <= 1:
return 1
else:
return (n + sum_func(n-1))
def sum_for():
total = 0
for n in range(1, 101):
total += n
return total
2023-12-27