# Enter a code
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if s1.isdisjoint(s2) != True:
for a in s1:
if a in s2:
print(a)
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
if s1.isdisjoint(s2) != True:
for a in s1:
if a in s2:
print(a)
2021-12-06
a = 0
i = 0
while True:
if a > 1000:
break
if a % 2 == 0:
i = i + a
a = a + 1
print(i)
i = 0
while True:
if a > 1000:
break
if a % 2 == 0:
i = i + a
a = a + 1
print(i)
2021-12-06
# Enter a code
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
s3=[]
for a in s1:
if a in s2:
s3.append(a)
else:
continue
print(s3)
s1 = set([1, 2, 3, 4, 5])
s2 = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
s3=[]
for a in s1:
if a in s2:
s3.append(a)
else:
continue
print(s3)
2021-12-06
age = 2
if age >= 18:
print('你是成年人,你{}歲了'.format(age))
print("adult")
elif age >= 6:
print('你是青少年,你{}歲了'.format(age))
print("teenager")
elif age >= 3:
print('你是小孩子,你{}歲了'.format(age))
print("kid")
else:
print('你是嬰兒,你{}歲了'.format(age))
print("baby")
if age >= 18:
print('你是成年人,你{}歲了'.format(age))
print("adult")
elif age >= 6:
print('你是青少年,你{}歲了'.format(age))
print("teenager")
elif age >= 3:
print('你是小孩子,你{}歲了'.format(age))
print("kid")
else:
print('你是嬰兒,你{}歲了'.format(age))
print("baby")
2021-12-05
age = 3
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")
2021-12-05
age=11
if age>=18:
print('adult')
print('咚咚嗆同學,你已成年')
else:
print('teenage')
print('咚咚嗆同學,你未成年')
if age>=18:
print('adult')
print('咚咚嗆同學,你已成年')
else:
print('teenage')
print('咚咚嗆同學,你未成年')
2021-12-05
#方案一
age=17
if age<18:
print("adult")
else:
print("minors")
#方案二
age = 17
if age >= 18:
print('your age = {}'.format(age))
print('adult')
else:
print('your age = {}'.format(age))
print('minors')
age=17
if age<18:
print("adult")
else:
print("minors")
#方案二
age = 17
if age >= 18:
print('your age = {}'.format(age))
print('adult')
else:
print('your age = {}'.format(age))
print('minors')
2021-12-05
#方法一:
a='AABCDEFGHHIJ'
b=a[1:9]
print(b)
#方法二:
a='AABCDEFGHHIJ'
print(a[1:9])
a='AABCDEFGHHIJ'
b=a[1:9]
print(b)
#方法二:
a='AABCDEFGHHIJ'
print(a[1:9])
2021-12-05
a='AABCDEFGHHIJ'
b=a[1:9]
print(b)
#方法二:
a='AABCDEFGHHIJ'
print(a[1:9])
b=a[1:9]
print(b)
#方法二:
a='AABCDEFGHHIJ'
print(a[1:9])
2021-12-05
a = "這是一句中英文混合的Python字符串:"
b = 'Hello World!'
print(a+b)
a = '這是一句中英文混合的Python字符串:Hello World!'
print(a)
b = 'Hello World!'
print(a+b)
a = '這是一句中英文混合的Python字符串:Hello World!'
print(a)
2021-12-05
a = 'python'
#a 是True,結果輸出='python'
print('hello,', a or 'world')
b = ''
#b 是False,結果輸出='world'
print('hello,', b or 'world')
#a 是True,結果輸出='python'
print('hello,', a or 'world')
b = ''
#b 是False,結果輸出='world'
print('hello,', b or 'world')
2021-12-05