1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| limits = { "高锰酸盐指数": [2, 4, 6, 10, 15], "氨氮": [0.15, 0.5, 1, 1.5, 2.0], "总磷": [0.02, 0.1, 0.2, 0.3, 0.4], "化学需氧量": [15, 15, 20, 30, 40], "五日生化需氧量": [3, 3, 4, 6, 10], "氟化物": [1, 1, 1, 1.5, 1.5], "pH": [6, 9], "溶解氧": [7.5, 6, 5, 3, 2] } def water_quality_level(monitoring_factor, value, limits): if monitoring_factor == "pH": if value < limits[monitoring_factor][0] or value > limits[monitoring_factor][1]: return "超标" else: return "正常" elif monitoring_factor == "溶解氧": if value >= limits[monitoring_factor][0]: return "Ⅰ" elif value >= limits[monitoring_factor][1]: return "Ⅱ" elif value >= limits[monitoring_factor][2]: return "Ⅲ" elif value >= limits[monitoring_factor][3]: return "Ⅳ" elif value >= limits[monitoring_factor][4]: return "Ⅴ" else: return "劣Ⅴ" else: if value <= limits[monitoring_factor][0]: return "Ⅰ" elif value <= limits[monitoring_factor][1]: return "Ⅱ" elif value <= limits[monitoring_factor][2]: return "Ⅲ" elif value <= limits[monitoring_factor][3]: return "Ⅳ" elif value <= limits[monitoring_factor][4]: return "Ⅴ" else: return "劣Ⅴ"
print(water_quality_level("pH", 5.5, limits)) print(water_quality_level("溶解氧", 6.5, limits))
|