{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.3 \u2014 Operators & Expressions\n",
    "\n",
    "Variables are only useful once you can *do* something with them. Today's about the operators that combine and compare values \u2014 the arithmetic you'd expect, plus a couple of Python-specific ones worth knowing early."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Idea\n",
    "\n",
    "The arithmetic operators: `+` `-` `*` `/` (regular division, always gives a `float`), `//` (floor division, drops the remainder), `%` (modulo, gives *just* the remainder), and `**` (exponent).\n",
    "\n",
    "```python\n",
    "17 // 5   # 3   -> how many times 5 fits into 17\n",
    "17 % 5    # 2   -> what's left over\n",
    "2 ** 3    # 8   -> 2 to the power of 3\n",
    "```\n",
    "\n",
    "Comparison operators (`==`, `!=`, `<`, `>`, `<=`, `>=`) compare two values and give back a `bool` \u2014 these are what you'll feed into conditionals starting next lesson.\n",
    "\n",
    "Python follows the same order of operations you learned in math class (exponents, then `*`/`/`/`//`/`%`, then `+`/`-`, left to right) \u2014 use parentheses `( )` whenever you want to force a different order."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# A worked example \u2014 Zara deals damage to the monster\n",
    "\n",
    "attack_power = 18\n",
    "monster_defense = 5\n",
    "damage_dealt = attack_power - monster_defense\n",
    "\n",
    "monster_health = 40\n",
    "monster_health = monster_health - damage_dealt\n",
    "\n",
    "print(\"Damage dealt:\", damage_dealt)\n",
    "print(\"Monster health remaining:\", monster_health)\n",
    "print(\"Is the monster defeated?\", monster_health <= 0)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Guided Practice 1\n",
    "\n",
    "Zara found some treasure. Run the cell as-is, then change the starting gold or the treasure amount and re-run."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Treasure found \u2014 change the values below and re-run\n",
    "\n",
    "starting_gold = 25\n",
    "treasure_found = 40\n",
    "total_gold = starting_gold + treasure_found\n",
    "\n",
    "print(\"Total gold:\", total_gold)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Guided Practice 2\n",
    "\n",
    "Old Finn is splitting a stack of 17 healing potions evenly between the two of you, with leftovers set aside. Fill in every `____`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Fill in the two blank values, then run \u2014 the operators are already correct\n",
    "\n",
    "total_potions = ____   # try 17\n",
    "people_sharing = ____  # try 2\n",
    "\n",
    "potions_each = total_potions // people_sharing      # floor division \u2014 whole potions each\n",
    "potions_leftover = total_potions % people_sharing   # modulo \u2014 what's left over\n",
    "\n",
    "print(\"Potions each:\", potions_each)\n",
    "print(\"Potions leftover:\", potions_leftover)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Independent Practice 1\n",
    "\n",
    "Zara wants to buy a shield that costs 30 gold. Write code that checks whether `total_gold` (use any starting value you like) is enough \u2014 use a comparison operator and print the result of the comparison (a `bool`).\n",
    "\n",
    "**Hint (only if stuck):** you don't need an `if` yet \u2014 just `print(total_gold >= 30)` after setting `total_gold` to a number."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Your code here \u2014 compare Zara's gold to the shield's price\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Independent Practice 2\n",
    "\n",
    "No hint this time. Zara lands a critical hit: her normal attack power should be **squared** for one turn. Calculate and print the critical hit damage using `**`, starting from any `attack_power` value you choose."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Your code here \u2014 calculate a critical hit using **\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Want More? (Optional)\n",
    "\n",
    "Zara's total gold needs converting into gold pieces and silver pieces (10 silver = 1 gold piece), given some total amount of silver. Use `//` to get the whole gold pieces and `%` to get the leftover silver, then print both."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Optional stretch \u2014 convert total silver into gold pieces + leftover silver\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Check Your Understanding\n",
    "\n",
    "In one sentence: what's the actual difference between `/` and `//`?"
   ]
  },
  {
   "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
}
