{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Topic 2: Practice problems (if and else)\n",
    "\n",
    "Asiman Data School, Module 1: Foundations of Python Programming. Week 1, Thursday.\n",
    "\n",
    "Fifteen problems in three levels, on the same ideas and at the same level as the lesson notebook.\n",
    "\n",
    "How to work\n",
    "\n",
    "- Write your code in the cell under each problem. The first lines read the input for you: when the cell runs, a small box appears, type the value there and press Enter.\n",
    "- Run your code with every row of the examples table and compare the output. Print exactly the text the problem asks for.\n",
    "- A hint and one possible solution are under each problem. Open them only after you have tried.\n",
    "\n",
    "Tip: for each problem, write down the cases on paper first, then the conditions, then the code. Test the boundary values."
   ],
   "id": "t02p-000"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Easy"
   ],
   "id": "t02p-001"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 1. Greater than 100\n",
    "\n",
    "Ask for a number and print whether it is greater than 100 or not: `Greater than 100` or `Not greater than 100`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `150` | `Greater than 100` |\n",
    "| `100` | `Not greater than 100` |\n",
    "| `99` | `Not greater than 100` |\n",
    "| `-5` | `Not greater than 100` |"
   ],
   "id": "t02p-002"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "number = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-003"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Two outcomes, so `if/else`. Is exactly 100 greater than 100?\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "number = int(input())\n",
    "\n",
    "if number > 100:\n",
    "    print(\"Greater than 100\")\n",
    "else:\n",
    "    print(\"Not greater than 100\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `150` | `Greater than 100` |\n",
    "| `100` | `Not greater than 100` |\n",
    "| `99` | `Not greater than 100` |\n",
    "| `-5` | `Not greater than 100` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-004"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 2. Divisible by 5\n",
    "\n",
    "Check whether a number is divisible by 5. Print `Divisible by 5` or `Not divisible by 5`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `25` | `Divisible by 5` |\n",
    "| `7` | `Not divisible by 5` |\n",
    "| `0` | `Divisible by 5` |\n",
    "| `-10` | `Divisible by 5` |"
   ],
   "id": "t02p-005"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "number = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-006"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "A number is divisible by 5 when the remainder `number % 5` is 0.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "number = int(input())\n",
    "\n",
    "if number % 5 == 0:\n",
    "    print(\"Divisible by 5\")\n",
    "else:\n",
    "    print(\"Not divisible by 5\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `25` | `Divisible by 5` |\n",
    "| `7` | `Not divisible by 5` |\n",
    "| `0` | `Divisible by 5` |\n",
    "| `-10` | `Divisible by 5` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-007"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 3. Teenager\n",
    "\n",
    "Check whether a person is a teenager (13 to 19 years old). Print `Teenager` or `Not a teenager`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `16` | `Teenager` |\n",
    "| `13` | `Teenager` |\n",
    "| `19` | `Teenager` |\n",
    "| `12` | `Not a teenager` |\n",
    "| `20` | `Not a teenager` |"
   ],
   "id": "t02p-008"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "age = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-009"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "A range check: `13 <= age <= 19`. Test 12, 13, 19 and 20.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "age = int(input())\n",
    "\n",
    "if 13 <= age <= 19:\n",
    "    print(\"Teenager\")\n",
    "else:\n",
    "    print(\"Not a teenager\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `16` | `Teenager` |\n",
    "| `13` | `Teenager` |\n",
    "| `19` | `Teenager` |\n",
    "| `12` | `Not a teenager` |\n",
    "| `20` | `Not a teenager` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-010"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 4. The smaller number\n",
    "\n",
    "Print the smaller of two numbers.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `3, 8` | `3` |\n",
    "| `8, 3` | `3` |\n",
    "| `5, 5` | `5` |\n",
    "| `-2, -7` | `-7` |"
   ],
   "id": "t02p-011"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = int(input())\n",
    "b = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-012"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Compare `a < b`. If the two numbers are equal, either one is the right answer.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "a = int(input())\n",
    "b = int(input())\n",
    "\n",
    "if a < b:\n",
    "    print(a)\n",
    "else:\n",
    "    print(b)\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `3, 8` | `3` |\n",
    "| `8, 3` | `3` |\n",
    "| `5, 5` | `5` |\n",
    "| `-2, -7` | `-7` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-013"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 5. Museum ticket\n",
    "\n",
    "A museum ticket costs 20. Children under 12 pay 10, and visitors aged 65 or more pay 15. Read the age and print the price like `Price: 20`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `8` | `Price: 10` |\n",
    "| `11` | `Price: 10` |\n",
    "| `12` | `Price: 20` |\n",
    "| `40` | `Price: 20` |\n",
    "| `64` | `Price: 20` |\n",
    "| `65` | `Price: 15` |\n",
    "| `70` | `Price: 15` |"
   ],
   "id": "t02p-014"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "age = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-015"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Three outcomes: `if`, `elif`, `else`. Store the price in a variable and print it once at the end. Test 11, 12, 64 and 65.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "age = int(input())\n",
    "\n",
    "if age < 12:\n",
    "    price = 10\n",
    "elif age >= 65:\n",
    "    price = 15\n",
    "else:\n",
    "    price = 20\n",
    "\n",
    "print(\"Price:\", price)\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `8` | `Price: 10` |\n",
    "| `11` | `Price: 10` |\n",
    "| `12` | `Price: 20` |\n",
    "| `40` | `Price: 20` |\n",
    "| `64` | `Price: 20` |\n",
    "| `65` | `Price: 15` |\n",
    "| `70` | `Price: 15` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-016"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Medium"
   ],
   "id": "t02p-017"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 6. Season\n",
    "\n",
    "Print the season from a month number (12, 1, 2 is `Winter`, 3 to 5 is `Spring`, 6 to 8 is `Summer`, 9 to 11 is `Autumn`). Print an error for other numbers: `Invalid month`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `1` | `Winter` |\n",
    "| `4` | `Spring` |\n",
    "| `7` | `Summer` |\n",
    "| `10` | `Autumn` |\n",
    "| `12` | `Winter` |\n",
    "| `2` | `Winter` |\n",
    "| `0` | `Invalid month` |\n",
    "| `13` | `Invalid month` |"
   ],
   "id": "t02p-018"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "month = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-019"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Check the invalid numbers first. Winter needs `or`, because 12 is not next to 1 and 2.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "month = int(input())\n",
    "\n",
    "if month < 1 or month > 12:\n",
    "    print(\"Invalid month\")\n",
    "elif month == 12 or month <= 2:\n",
    "    print(\"Winter\")\n",
    "elif month <= 5:\n",
    "    print(\"Spring\")\n",
    "elif month <= 8:\n",
    "    print(\"Summer\")\n",
    "else:\n",
    "    print(\"Autumn\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `1` | `Winter` |\n",
    "| `4` | `Spring` |\n",
    "| `7` | `Summer` |\n",
    "| `10` | `Autumn` |\n",
    "| `12` | `Winter` |\n",
    "| `2` | `Winter` |\n",
    "| `0` | `Invalid month` |\n",
    "| `13` | `Invalid month` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-020"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 7. Greeting\n",
    "\n",
    "Convert a time (hour from 0 to 23) into `Good morning`, `Good afternoon`, `Good evening`, or `Good night`: 5 to 11 is morning, 12 to 17 is afternoon, 18 to 21 is evening, and every other hour is night.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `9` | `Good morning` |\n",
    "| `5` | `Good morning` |\n",
    "| `11` | `Good morning` |\n",
    "| `12` | `Good afternoon` |\n",
    "| `17` | `Good afternoon` |\n",
    "| `18` | `Good evening` |\n",
    "| `21` | `Good evening` |\n",
    "| `22` | `Good night` |\n",
    "| `3` | `Good night` |"
   ],
   "id": "t02p-021"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "hour = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-022"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Night is split in two (22 to 23 and 0 to 4), so let `else` catch it. Use chained comparisons like `5 <= hour <= 11`.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "hour = int(input())\n",
    "\n",
    "if 5 <= hour <= 11:\n",
    "    print(\"Good morning\")\n",
    "elif 12 <= hour <= 17:\n",
    "    print(\"Good afternoon\")\n",
    "elif 18 <= hour <= 21:\n",
    "    print(\"Good evening\")\n",
    "else:\n",
    "    print(\"Good night\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `9` | `Good morning` |\n",
    "| `5` | `Good morning` |\n",
    "| `11` | `Good morning` |\n",
    "| `12` | `Good afternoon` |\n",
    "| `17` | `Good afternoon` |\n",
    "| `18` | `Good evening` |\n",
    "| `21` | `Good evening` |\n",
    "| `22` | `Good night` |\n",
    "| `3` | `Good night` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-023"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 8. Water state\n",
    "\n",
    "Water state: at or below 0 °C is `Ice`, between 0 and 100 is `Liquid`, at or above 100 is `Steam`. The temperature can be a decimal number.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `25` | `Liquid` |\n",
    "| `0` | `Ice` |\n",
    "| `-5` | `Ice` |\n",
    "| `0.5` | `Liquid` |\n",
    "| `99.9` | `Liquid` |\n",
    "| `100` | `Steam` |\n",
    "| `130` | `Steam` |"
   ],
   "id": "t02p-024"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "temperature = float(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-025"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Read the value with `float(input())`. Go from the lowest limit upward: `<= 0`, then `< 100`, then `else`.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "temperature = float(input())\n",
    "\n",
    "if temperature <= 0:\n",
    "    print(\"Ice\")\n",
    "elif temperature < 100:\n",
    "    print(\"Liquid\")\n",
    "else:\n",
    "    print(\"Steam\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `25` | `Liquid` |\n",
    "| `0` | `Ice` |\n",
    "| `-5` | `Ice` |\n",
    "| `0.5` | `Liquid` |\n",
    "| `99.9` | `Liquid` |\n",
    "| `100` | `Steam` |\n",
    "| `130` | `Steam` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-026"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 9. Password\n",
    "\n",
    "A password is accepted only if it equals `\"python123\"` or equals `\"admin2026\"`. Print `Access granted` or `Access denied`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `python123` | `Access granted` |\n",
    "| `admin2026` | `Access granted` |\n",
    "| `Python123` | `Access denied` |\n",
    "| `hello` | `Access denied` |"
   ],
   "id": "t02p-027"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "password = input()\n",
    "# Write your code here"
   ],
   "id": "t02p-028"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "The password is text, so no conversion. Repeat the full comparison on both sides of `or`. Passwords are case-sensitive.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "password = input()\n",
    "\n",
    "if password == \"python123\" or password == \"admin2026\":\n",
    "    print(\"Access granted\")\n",
    "else:\n",
    "    print(\"Access denied\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `python123` | `Access granted` |\n",
    "| `admin2026` | `Access granted` |\n",
    "| `Python123` | `Access denied` |\n",
    "| `hello` | `Access denied` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-029"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 10. Taxi fare\n",
    "\n",
    "Taxi fare: a base fare of 3, plus 1.5 per km for the first 10 km and 1.2 per km after that. Add a night surcharge of 2 if the hour is 22 or later or before 6. Read the distance and the hour, and print the fare like `Fare: 10.5`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `5, 14` | `Fare: 10.5` |\n",
    "| `10, 14` | `Fare: 18.0` |\n",
    "| `15, 14` | `Fare: 24.0` |\n",
    "| `15, 23` | `Fare: 26.0` |\n",
    "| `2, 5` | `Fare: 8.0` |\n",
    "| `20, 22` | `Fare: 32.0` |"
   ],
   "id": "t02p-030"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "km = float(input())\n",
    "hour = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-031"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Two separate decisions in sequence. First the distance: for more than 10 km the price is `10 * 1.5 + (km - 10) * 1.2`. Then the night check with `or`.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "km = float(input())\n",
    "hour = int(input())\n",
    "\n",
    "fare = 3\n",
    "\n",
    "if km <= 10:\n",
    "    fare = fare + km * 1.5\n",
    "else:\n",
    "    fare = fare + 10 * 1.5 + (km - 10) * 1.2\n",
    "\n",
    "if hour >= 22 or hour < 6:\n",
    "    fare = fare + 2\n",
    "\n",
    "print(\"Fare:\", round(fare, 2))\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `5, 14` | `Fare: 10.5` |\n",
    "| `10, 14` | `Fare: 18.0` |\n",
    "| `15, 14` | `Fare: 24.0` |\n",
    "| `15, 23` | `Fare: 26.0` |\n",
    "| `2, 5` | `Fare: 8.0` |\n",
    "| `20, 22` | `Fare: 32.0` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-032"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 11. Exam result\n",
    "\n",
    "Exam result: a student passes with a score of at least 50 **and** an attendance of at least 75 (percent). Read the score and the attendance. Print `Pass with distinction` for a pass with a score of 90 or more, `Pass` for other passes, and for a fail say why: `Fail: low score`, `Fail: low attendance`, or `Fail: low score and low attendance`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `70, 90` | `Pass` |\n",
    "| `95, 80` | `Pass with distinction` |\n",
    "| `50, 75` | `Pass` |\n",
    "| `40, 90` | `Fail: low score` |\n",
    "| `80, 60` | `Fail: low attendance` |\n",
    "| `30, 50` | `Fail: low score and low attendance` |\n",
    "| `90, 74` | `Fail: low attendance` |"
   ],
   "id": "t02p-033"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "score = int(input())\n",
    "attendance = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-034"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "First decide pass or fail with `and`. Inside the pass block, ask the second question about 90. For the fails, check the \"both\" case first.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "score = int(input())\n",
    "attendance = int(input())\n",
    "\n",
    "if score >= 50 and attendance >= 75:\n",
    "    if score >= 90:\n",
    "        print(\"Pass with distinction\")\n",
    "    else:\n",
    "        print(\"Pass\")\n",
    "elif score < 50 and attendance < 75:\n",
    "    print(\"Fail: low score and low attendance\")\n",
    "elif score < 50:\n",
    "    print(\"Fail: low score\")\n",
    "else:\n",
    "    print(\"Fail: low attendance\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `70, 90` | `Pass` |\n",
    "| `95, 80` | `Pass with distinction` |\n",
    "| `50, 75` | `Pass` |\n",
    "| `40, 90` | `Fail: low score` |\n",
    "| `80, 60` | `Fail: low attendance` |\n",
    "| `30, 50` | `Fail: low score and low attendance` |\n",
    "| `90, 74` | `Fail: low attendance` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-035"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Medium-Hard"
   ],
   "id": "t02p-036"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 12. Three numbers in order\n",
    "\n",
    "Given three numbers, print them in order from smallest to largest using only `if/elif/else`, on one line like `1 2 3`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `3, 1, 2` | `1 2 3` |\n",
    "| `1, 2, 3` | `1 2 3` |\n",
    "| `3, 2, 1` | `1 2 3` |\n",
    "| `2, 3, 1` | `1 2 3` |\n",
    "| `5, 5, 1` | `1 5 5` |\n",
    "| `7, 7, 7` | `7 7 7` |\n",
    "| `-1, -5, 0` | `-5 -1 0` |"
   ],
   "id": "t02p-037"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = int(input())\n",
    "b = int(input())\n",
    "c = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-038"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Find the smallest first (it must be `<=` both others). Then one more comparison puts the other two in order. `print(a, b, c)` prints three values on one line.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "a = int(input())\n",
    "b = int(input())\n",
    "c = int(input())\n",
    "\n",
    "if a <= b and a <= c:\n",
    "    if b <= c:\n",
    "        print(a, b, c)\n",
    "    else:\n",
    "        print(a, c, b)\n",
    "elif b <= a and b <= c:\n",
    "    if a <= c:\n",
    "        print(b, a, c)\n",
    "    else:\n",
    "        print(b, c, a)\n",
    "else:\n",
    "    if a <= b:\n",
    "        print(c, a, b)\n",
    "    else:\n",
    "        print(c, b, a)\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `3, 1, 2` | `1 2 3` |\n",
    "| `1, 2, 3` | `1 2 3` |\n",
    "| `3, 2, 1` | `1 2 3` |\n",
    "| `2, 3, 1` | `1 2 3` |\n",
    "| `5, 5, 1` | `1 5 5` |\n",
    "| `7, 7, 7` | `7 7 7` |\n",
    "| `-1, -5, 0` | `-5 -1 0` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-039"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 13. Days in the year\n",
    "\n",
    "Given a year, print the number of days in the year (`365` or `366`).\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `2024` | `366` |\n",
    "| `2023` | `365` |\n",
    "| `1900` | `365` |\n",
    "| `2000` | `366` |"
   ],
   "id": "t02p-040"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "year = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-041"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Reuse the leap-year rule from solved problem 13. Test the century years 1900 and 2000.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "year = int(input())\n",
    "\n",
    "if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:\n",
    "    print(366)\n",
    "else:\n",
    "    print(365)\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `2024` | `366` |\n",
    "| `2023` | `365` |\n",
    "| `1900` | `365` |\n",
    "| `2000` | `366` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-042"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 14. Right-angled triangle\n",
    "\n",
    "Check whether three numbers could be the sides of a right-angled triangle (use a² + b² = c² with the longest side as c). Print `Right-angled` or `Not right-angled`.\n",
    "\n",
    "Examples\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `3, 4, 5` | `Right-angled` |\n",
    "| `5, 3, 4` | `Right-angled` |\n",
    "| `13, 5, 12` | `Right-angled` |\n",
    "| `2, 3, 4` | `Not right-angled` |\n",
    "| `1, 1, 1` | `Not right-angled` |\n",
    "| `6, 10, 8` | `Right-angled` |"
   ],
   "id": "t02p-043"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = int(input())\n",
    "b = int(input())\n",
    "c = int(input())\n",
    "# Write your code here"
   ],
   "id": "t02p-044"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "The longest side is not always the third number. First find it (like solved problem 5), then compare the squares with `**` and `==`.\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "a = int(input())\n",
    "b = int(input())\n",
    "c = int(input())\n",
    "\n",
    "# find the longest side first\n",
    "if a >= b and a >= c:\n",
    "    longest = a\n",
    "    x = b\n",
    "    y = c\n",
    "elif b >= a and b >= c:\n",
    "    longest = b\n",
    "    x = a\n",
    "    y = c\n",
    "else:\n",
    "    longest = c\n",
    "    x = a\n",
    "    y = b\n",
    "\n",
    "if x ** 2 + y ** 2 == longest ** 2:\n",
    "    print(\"Right-angled\")\n",
    "else:\n",
    "    print(\"Not right-angled\")\n",
    "```\n",
    "\n",
    "**Test cases**\n",
    "\n",
    "| Input | Output |\n",
    "|---|---|\n",
    "| `3, 4, 5` | `Right-angled` |\n",
    "| `5, 3, 4` | `Right-angled` |\n",
    "| `13, 5, 12` | `Right-angled` |\n",
    "| `2, 3, 4` | `Not right-angled` |\n",
    "| `1, 1, 1` | `Not right-angled` |\n",
    "| `6, 10, 8` | `Right-angled` |\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-045"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem 15. Phone-plan advisor\n",
    "\n",
    "A phone-plan advisor: given monthly minutes and monthly gigabytes used, recommend `Basic`, `Standard`, or `Premium` using your own rules. Write your rules down as comments first."
   ],
   "id": "t02p-046"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "minutes = 320\n",
    "gigabytes = 12\n",
    "# Write your rules as comments, then your code"
   ],
   "id": "t02p-047"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<details>\n",
    "<summary><b>Show a hint</b></summary>\n",
    "\n",
    "Decide the limits for Premium first (the strictest rule), then Standard, and let `else` be Basic. Should a plan need many minutes `and` many gigabytes, or is one of them enough (`or`)?\n",
    "\n",
    "</details>\n",
    "\n",
    "<details>\n",
    "<summary><b>Show the solution</b></summary>\n",
    "\n",
    "```python\n",
    "minutes = 320\n",
    "gigabytes = 12\n",
    "\n",
    "if minutes > 1000 or gigabytes > 20:\n",
    "    plan = \"Premium\"\n",
    "elif minutes > 300 or gigabytes > 5:\n",
    "    plan = \"Standard\"\n",
    "else:\n",
    "    plan = \"Basic\"\n",
    "\n",
    "print(\"Recommended plan:\", plan)\n",
    "```\n",
    "\n",
    "**Output**\n",
    "\n",
    "```\n",
    "Recommended plan: Standard\n",
    "```\n",
    "\n",
    "Your rules can be different. What matters is that the strictest rule is checked first.\n",
    "\n",
    "</details>"
   ],
   "id": "t02p-048"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When you have finished, compare your solutions with the hidden ones. A different solution that passes every example is just as good."
   ],
   "id": "t02p-049"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
