python_for_asl/Exercise/exercise-4.1.py
2025-08-06 02:04:35 +08:00

33 lines
686 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 我们希望将患者按照信息分别按照性别和年龄分成4个组别分别存储他们的姓名
patient_info = [
["Zhang San", 52, "M"],
["Li Si", 19, "F"],
["Wang Wu", 47, "F"],
["Zhao Liu", 29, "M"],
]
group_M_under_30 = []
group_M_over_30 = []
group_F_under_30 = []
group_F_over_30 = []
for patient in patient_info:
print('new patient:', patient)
# 补充代码使用条件判断将患者分为4组分别存储他们的姓名即可
# 应当为 ["Zhao Liu"]
print(group_M_under_30)
# 应当为 ["Zhang San"]
print(group_M_over_30)
# 应当为 ["Li Si"]
print(group_F_under_30)
# 应当为 ["Wang Wu"]
print(group_F_over_30)