Quick actions

cmd+k|ctrl+k

Navigation

Languages

交集intersection a&b 

Snippet info

Language

Python

Visibility

public

Author

yayinchan

Created

2026-01-12T17:04:27.080543Z

Updated

2026-01-21T12:14:02.720334Z

# 交集intersection a&b 、聯集union a|b、差集difference a-b、對稱集symmetric a^b     
''' P57-58'''
asiacountry={"China", "Japan", "Korea"}
worldcountry={"Germany", "China", "Spain", "Italy", "Japan"}
print(asiacountry)
print(worldcountry)

country=asiacountry & worldcountry
print(country)
country=asiacountry.intersection(worldcountry)
print(country)


'''country=asiacountry|worldcountry
print(country)'''

country=asiacountry.union(worldcountry)
print(country)

INFO