論理演算子のポーション
幻想の森の奥深くで、あなたは正確な素材が必要なポーションを作る任務を与えられました。アルダーはあなたに Python スクリプトで論理演算子and、or、およびnotの使い方を教えました。
このステップでは、日付の天候と湿度条件に基づいて必要な素材を決定する呪文を作成します。
/home/labex/project/potion_ingredients.pyというファイルに以下の呪文を書きます:
## Determine the needed potion ingredients
weather = "sunny"
humidity = "high"
if weather == "rainy" and humidity == "high":
print("Add a sunflower petal to counter the rain.")
elif weather == "sunny" or humidity == "moderate":
print("Add a drop of honey for sweetness.")
else:
print("No special ingredients are needed today.")
以下のコマンドで呪文を実行します:
python /home/labex/project/potion_ingredients.py
以下のメッセージが表示されるはずです:
Add a drop of honey for sweetness.