{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.4 \u2014 Conditionals\n",
    "\n",
    "Every program you've written so far runs the exact same way every time. Conditionals change that \u2014 your code can finally make decisions, which means Zara's story can actually branch."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Idea\n",
    "\n",
    "`if` runs a block of code only when a condition is `True`. Add `elif` for more conditions to check, and `else` to catch everything else:\n",
    "\n",
    "```python\n",
    "if health <= 0:\n",
    "    print(\"Game over.\")\n",
    "elif health < 20:\n",
    "    print(\"Critically wounded!\")\n",
    "else:\n",
    "    print(\"Still standing.\")\n",
    "```\n",
    "\n",
    "Python checks conditions top to bottom and runs the **first** one that's `True` \u2014 the rest are skipped, even if they'd also be `True`. Combine conditions with `and` (both must be true), `or` (at least one must be true), and `not` (flips a `bool`).\n",
    "\n",
    "*Watch out for:* `=` assigns a value; `==` compares two values. Mixing them up is one of the most common bugs in this lesson \u2014 and confusingly, `if health = 100:` isn't just wrong, it's a `SyntaxError`, so at least Python won't let it run silently."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# A worked example \u2014 checking if Zara can still fight\n",
    "\n",
    "health = 15\n",
    "\n",
    "if health <= 0:\n",
    "    print(\"Zara has fallen.\")\n",
    "elif health < 20:\n",
    "    print(\"Zara is critically wounded, but still fighting!\")\n",
    "else:\n",
    "    print(\"Zara is in good shape.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Guided Practice 1\n",
    "\n",
    "Zara wants to buy a shield. Run the cell as-is, then change `total_gold` or `shield_price` and re-run to see both outcomes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Change the values below and re-run\n",
    "\n",
    "total_gold = 45\n",
    "shield_price = 30\n",
    "\n",
    "if total_gold >= shield_price:\n",
    "    print(\"You can afford the shield.\")\n",
    "else:\n",
    "    print(\"Not enough gold yet.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Guided Practice 2\n",
    "\n",
    "Sort the monster into a difficulty tier based on its health. Fill in every `____`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Fill in the two blank thresholds, then run \u2014 the structure is already correct\n",
    "\n",
    "monster_health = 65\n",
    "\n",
    "if monster_health < ____:      # try 20\n",
    "    print(\"Easy fight.\")\n",
    "elif monster_health < ____:    # try 60\n",
    "    print(\"Moderate fight.\")\n",
    "else:\n",
    "    print(\"Tough fight \u2014 be careful.\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Independent Practice 1\n",
    "\n",
    "Old Finn will only join your party if his `trust_level` is at least `0.5` **and** Zara's `health` is above `10` (he won't tag along with someone about to collapse). Write the conditional and print whether he joins.\n",
    "\n",
    "**Hint (only if stuck):** `if trust_level >= 0.5 and health > 10:` \u2014 set both variables to whatever values you like above the `if`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Your code here \u2014 decide whether Old Finn joins the party\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Independent Practice 2\n",
    "\n",
    "No hint this time. Ask the player (with `input()`) whether Zara should \"fight\" or \"flee\" the monster. Print a different message depending on which they typed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Your code here \u2014 ask fight or flee, print a different message for each\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Want More? (Optional)\n",
    "\n",
    "Zara can only enter the locked room if she **has the key** (a `bool`) **and** her health is above `20`. Write the combined condition with `and`, and print a message either way."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Optional stretch \u2014 combine two conditions with \"and\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Check Your Understanding\n",
    "\n",
    "In one sentence: what actually happens differently if you write a second `if` instead of an `elif`?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Your answer:** *(double-click to edit this cell)*"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
