HW3

1.Notebook
2.
3.學習卡與測驗











4.
# 3. Choose an Activity Based on Temperature and Humidity 🌦️⚽

## 📌 Description
This Python program recommends an activity based on the temperature and humidity entered by the user. 
The program uses `if`, `else`, and logical operators to determine which activity to play.

---

## 💻 Python Code

```python
# activity_selector.py

temp = input('Enter the temperature (warm/cold): ').strip().lower()
hum = input('Enter humidity (humid/dry): ').strip().lower()

# Decision Logic
if temp == 'warm' and hum == 'dry':
    print('Play Basketball')
elif temp == 'warm' and hum == 'humid':
    print('Play Tennis')
elif temp == 'cold' and hum == 'dry':
    print('Play Cricket')
else:
    print('Swim')
```

---

## 🧠 Decision Rules

| Temperature | Humidity | Activity |
| :--- | :--- | :--- |
| warm | dry | Play Basketball |
| warm | humid | Play Tennis |
| cold | dry | Play Cricket |
| cold | humid | Swim |

## ▶️ Example Output
```text
Enter the temperature (warm/cold): cold
Enter humidity (humid/dry): humid
Swim
```

## 📝 Explanation
* **`input()`** asks the user to enter the temperature and humidity.
* **`if`** checks whether the temperature is warm and the humidity is dry.
* **`elif`** checks other possible combinations.
* The **`and`** operator means both conditions must be true.
* **`else`** runs when none of the previous conditions is true.
* **`print()`** displays the recommended activity.

## 🛠️ Requirements
* Python 3.x

## 🚀 How to Run
1. Save the program as `activity_selector.py`.
2. Open a terminal or command prompt.
3. Run the following command:
   ```bash
   python activity_selector.py
   ```

## 📚 Learning Objectives
* Using `input()` to receive user input.
* Using `if`, `elif`, and `else` statements.
* Applying the logical operator `and`.
* Making decisions based on multiple conditions.

## 📄 License
This project is for educational purposes.

---

# 中文程式說明

這個程式會根據使用者輸入的溫度(Temperature)和濕度(Humidity),決定要進行哪一種活動。

## 判斷規則
* **溫暖(warm)+乾燥(dry)**:打籃球(Play Basketball)。
* **溫暖(warm)+潮濕(humid)**:打網球(Play Tennis)。
* **寒冷(cold)+乾燥(dry)**:打板球(Play Cricket)。
* **寒冷(cold)+潮濕(humid)**:游泳(Swim)。

## 重要語法
* **`if`**:判斷第一個條件是否成立。
* **`elif`**:當前面的條件不成立時,繼續判斷其他條件。
* **`else`**:當前面所有條件都不成立時,執行最後的指令。
* **`and`**:表示兩個條件必須同時成立。
```

留言

這個網誌中的熱門文章

HW2