chinese = '這是一句中英文混合的Python字符串'
english = 'Hello World!'
print (chinese + ':' + english)
english = 'Hello World!'
print (chinese + ':' + english)
2022-10-09
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-10-09
length = 3.14
wide = 1.57
area = length * wide
result = round(area,2)
print(result)
wide = 1.57
area = length * wide
result = round(area,2)
print(result)
2022-10-09
L = [75, 92, 59, 68, 99]
sum = 0
for c in L:
sum = c+sum
print(sum/len(L))
sum = 0
for c in L:
sum = c+sum
print(sum/len(L))
2022-10-08
s = 'AABCDEFGHHIJ'
b = []
for a in s[0:-2]:
if a not in b:
b.append(a)
s1 = ''.join(b)
print(s1)
b = []
for a in s[0:-2]:
if a not in b:
b.append(a)
s1 = ''.join(b)
print(s1)
2022-10-08
a = 0
L = ['Alice', 66, 'Bob', True, 'False', 100]
while a < len(L):
print(L[a])
a=a+2
L = ['Alice', 66, 'Bob', True, 'False', 100]
while a < len(L):
print(L[a])
a=a+2
2022-10-07
def sub_sum(L):
n=0
s1=0
s2=0
for n in L:
if n%2==0:
s1=s1+n
else:
s2=s2+n
return s1, s2
L = (1, 2, 3, 4, 5, 6)
s1, s2 = sub_sum(L)
print(s1)
print(s2)
n=0
s1=0
s2=0
for n in L:
if n%2==0:
s1=s1+n
else:
s2=s2+n
return s1, s2
L = (1, 2, 3, 4, 5, 6)
s1, s2 = sub_sum(L)
print(s1)
print(s2)
2022-10-06
L1 = list()
L2 = list()
n = 0
while n<=99:
n = n+1
L1.append(n)
a = n*n
L2.append(a)
print(L1)
print(L2)
S1 = sum(L1)
print(S1)
S2 = sum(L2)
print(S2)
L2 = list()
n = 0
while n<=99:
n = n+1
L1.append(n)
a = n*n
L2.append(a)
print(L1)
print(L2)
S1 = sum(L1)
print(S1)
S2 = sum(L2)
print(S2)
2022-10-06
L = list()
n = 0
while n<=99:
n = n+1
L.append(n)
print(L)
S = sum(L)
print(S)
n = 0
while n<=99:
n = n+1
L.append(n)
print(L)
S = sum(L)
print(S)
2022-10-06
L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
S = set([1, 3, 5, 7, 9, 11])
for i in L:
if i in S:
S.remove(i)
else:
S.add(i)
print(S)
S = set([1, 3, 5, 7, 9, 11])
for i in L:
if i in S:
S.remove(i)
else:
S.add(i)
print(S)
2022-10-06
names = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name_set = set(names)
print('請輸入查詢名字')
p=input()
s=p.lower()
for name in name_set:
if s in name.lower():
print('存在')
break
else:
print('不存在')
break
name_set = set(names)
print('請輸入查詢名字')
p=input()
s=p.lower()
for name in name_set:
if s in name.lower():
print('存在')
break
else:
print('不存在')
break
2022-10-06
d = {'Alice': [50, 61, 66], 'Bob': [80, 61, 66], 'Candy': [88, 75, 90]}
num = 0
for value in d.values():
for x in value:
num+=1
print(num)
num = 0
for value in d.values():
for x in value:
num+=1
print(num)
2022-10-06