set_data1 = {1, 2, 3, 4}
set_data2 = {2, 3, 5}
set_data = set_data1.intersection(set_data2)
print(set_data)
set_data = set_data1.union(set_data2)
print(set_data)
set_data = set_data1.difference(set_data2)
print(set_data)
condition1 = 1 < 10
condition2 = 1 > 10
print(condition1 and condition2)
print(condition1 or condition2)
data = ""
if data is None:
print("None")
else:
print("此变量不为空")
list_data = [1, 2, 3]
if 4 in list_data:
print("列表包含这个值")
else:
print("列表不包含这个值")
dict_data = {"张三": 21, "李四": 20, "王五": 19, "赵六": 18, "刘七": 19, "张麻子": 20, "耿耿": 20, "余淮": 19}
c_people = 0
p_people = 0
j_people = 0
g_people = 0
for grade in dict_data.values():
if grade == 21:
c_people += 1
elif grade == 20:
p_people += 1
elif grade == 19:
j_people += 1
elif grade == 18:
g_people += 1
print("c语言:", c_people, ";python:", p_people, ";java:", j_people, ";go:", g_people)
dict_data = {"张三": 21, "李四": 20, "王五": 19, "赵六": 18, "刘七": 19, "张麻子": 20, "耿耿": 20, "余淮": 19}
for name in dict_data:
print(name, end="\t")
print()
for grade in dict_data.values():
print(grade, end="\t")
print()
for people in dict_data.items():
print(people, end="\t")
print()
tuple_data = (1, 2, 3, 4, 5, 6)
for index, num in enumerate(tuple_data):
print(index, num)