HW03 判斷敘述式

 HW03 判斷敘述式

1.notebook

2.YOUTUBE


3.單字卡和測驗


4.115103112%5+1=3
# 運動決策程式說明

此程式會根據使用者輸入的**溫度**(`warm` 或 `cold`)與**濕度**(`dry` 或 `humid`)來推薦適合的運動:
- 溫暖且乾燥 (`warm` + `dry`): 推薦打籃球 (Play Basketball)
- 溫暖且潮濕 (`warm` + `humid`): 推薦打網球 (Play Tennis)
- 寒冷且乾燥 (`cold` + `dry`): 推薦打板球 (Play Cricket)
- 其他所有狀況 (如寒冷且潮濕): 推薦游泳 (Swim)
# 修正縮排與輸入提示後的 Python 程式
temp = input('Enter the temperature (warm / cold): ').strip().lower()
hum = input('Enter humidity (dry / humid): ').strip().lower()

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')
# GitHub README.md

您可以將以下內容複製並儲存為您 GitHub 專案中的 `README.md` 檔案:

```markdown # Weather-Based Sport Recommender A simple Python program that recommends an outdoor sport activity based on user inputs for temperature and humidity. ## Table of Contents - [Features](#features) - [Rules](#rules) - [How to Run](#how-to-run) - [Example](#example) ## Features - Simple CLI (Command Line Interface) input. - Input sanitization (automatically converts input to lowercase and strips whitespace). - Clear conditional logic. ## Rules | Temperature | Humidity | Recommended Sport | | :--- | :--- | :--- | | Warm | Dry | Play Basketball | | Warm | Humid | Play Tennis | | Cold | Dry | Play Cricket | | Any other combination | Swim | ## How to Run 1. Make sure you have Python installed (Python 3.x recommended). 2. Clone this repository: ```bash git clone https://github.com/your-username/your-repo-name.git ``` 3. Navigate to the folder and run the script: ```bash python main.py ``` ## Example ```text Enter the temperature (warm / cold): cold Enter humidity (dry / humid): humid Swim ```
```

















留言

這個網誌中的熱門文章

hw01 python 基礎

HW02 Python運算子表達式