print(r''' "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.''')
2022-11-24
s = 0
a = 0
while True:
if s >= 1000:
break
s = s + 2
a = a + s
print(a)
更簡單
a = 0
while True:
if s >= 1000:
break
s = s + 2
a = a + s
print(a)
更簡單
2022-11-24
def sub_sum(l):
x = []
y = []
for i in range(len(l)):
if i % 2 ==0:
x.append(l[i]*l[i])
else:
y.append(l[i]*l[i])
print("奇數位平方和為{0},\n偶數位平方和為{1}".format(sum(x),sum(y)))
sub_sum([1,2,3,4])
x = []
y = []
for i in range(len(l)):
if i % 2 ==0:
x.append(l[i]*l[i])
else:
y.append(l[i]*l[i])
print("奇數位平方和為{0},\n偶數位平方和為{1}".format(sum(x),sum(y)))
sub_sum([1,2,3,4])
2022-11-22
def square_of_sum(l):
for i in l:
eg = []
eg.append(i * i)
sum(eg)
print(sum(eg))
square_of_sum([1, 3, 5, 7])
for i in l:
eg = []
eg.append(i * i)
sum(eg)
print(sum(eg))
square_of_sum([1, 3, 5, 7])
2022-11-22
names=['Alice','Bob','David','Ellena']
news=['Zero','Phoebe','Gen']
news.sort()
print(news)
count=len(names)
for n in news:
names.insert(count,n)
count+=1
print(names)
news=['Zero','Phoebe','Gen']
news.sort()
print(news)
count=len(names)
for n in news:
names.insert(count,n)
count+=1
print(names)
2022-11-19
def x (n) :
result=0
for i in n:
result result+i
return result
print (x(n))
result=0
for i in n:
result result+i
return result
print (x(n))
2022-11-07
print(r"""'To be, or not to be:
that is the question.
Whether it's nobler in the mind to suffer.'""")
that is the question.
Whether it's nobler in the mind to suffer.'""")
2022-11-01
print(r"""'\"To be, or not to be\": that is the question.\n Whether it\'s nobler in the mind to suffer.'""")
2022-11-01
age = 1
if age>=18:
print('adult')
elif age>=6:
print('teenager')
elif age>=3:
print('kid')
else:
print('baby')
嘿嘿,可以這么寫
if age>=18:
print('adult')
elif age>=6:
print('teenager')
elif age>=3:
print('kid')
else:
print('baby')
嘿嘿,可以這么寫
2022-10-28