HW03 判斷敘述式
2.


Weather-Based Activity Recommender (氣候活動推薦器)
A simple Python program that recommends an activity (Basketball, Tennis, Cricket, or Swimming) based on user-inputted temperature and humidity conditions.
這個簡單 Python 程式根據使用者輸入的溫度與濕度條件,推薦適合的運動活動(籃球、網球、板球或游泳)。
📋 Table of Contents / 目錄
🌟 Features / 特點
Simple command-line interface (CLI) for user inputs.
Nested conditional logic (
if-else) to determine recommendations.Interactive decision-making based on environmental factors.
🧠 How It Works / 運作邏輯
The program asks the user for two inputs:
Temperature (
temp):warmorcoldHumidity (
hum):humidordry
Based on the combination of these inputs, the script determines the best activity:
Warm & Dry: Play Basketball 🏀
Warm & Humid: Play Tennis 🎾
Cold & Dry: Play Cricket 🏏
Cold & Humid (or any other input): Swim 🏊
📊 Decision Matrix / 決策矩陣
Temperature (溫度) | Humidity (濕度) | Recommended Activity (推薦活動) |
Warm | Dry | Play Basketball |
Warm | Humid | Play Tennis |
Cold | Dry | Play Cricket |
Cold | Humid | Swim |
🚀 Getting Started / 如何執行
Prerequisites / 需求標配
Python 3.x installed on your system.
Running the Script / 執行腳本
Clone this repository or copy the code:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-nameRun the Python script using your terminal or command prompt:
python main.py
💡 Usage Example / 使用範例
Enter the temperature:(a) warm b) cold): cold
Enter humidity: (a) humid b) dry): humid
Swim
📝 Code Implementation / 程式碼說明
# Activity Recommendation Script
temp = input('Enter the temperature:(a) warm b) cold): ')
hum = input('Enter humidity: (a) humid b) dry): ')
if temp == 'warm' and hum == 'dry':
print('Play Basketball')
else:
if temp == 'warm' and hum == 'humid':
print('Play Tennis')
else:
if temp == 'cold' and hum == 'dry':
print('Play Cricket')
else:
print('Swim')
📄 License
This project is open source and available under the MIT License.








留言
張貼留言