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
# Enter a code
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if not s1.isdisjoint(s2):
print(s1.intersection(s2))
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if not s1.isdisjoint(s2):
print(s1.intersection(s2))
2023-12-27
# Enter a code
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for n in L:
if n not in S:
S.add(n)
else:
S.remove(n)
print(S)
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for n in L:
if n not in S:
S.add(n)
else:
S.remove(n)
print(S)
2023-12-27
# Enter a code
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.append('Zero')
L.append('Phoebe')
L.append('Gen')
L.sort()
print(L)
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
L.append('Zero')
L.append('Phoebe')
L.append('Gen')
L.sort()
print(L)
2023-12-27