{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "829333fc",
   "metadata": {},
   "source": [
    "Συνθήκες - παραδείγματα"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "781328ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 4\n",
    "if a > 0:\n",
    "    print('Positive')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ae06fbbc",
   "metadata": {},
   "outputs": [],
   "source": [
    "flag = a > 0\n",
    "if flag:\n",
    "    print('Positive')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f60ec047",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Πιο σύνθετες συνθήκες\n",
    "x = 5\n",
    "y = 12\n",
    "\n",
    "if x > 0 and x < 10:\n",
    "    print('0 < x < 10')\n",
    "\n",
    "if 0 < x < 10: #η python επιτρέπει την συνεπτυγμένη μορφή\n",
    "    print('0 < x < 10')\n",
    "\n",
    "if x < 10 or x > 20:\n",
    "    print('x not in [10, 20]')\n",
    "\n",
    "if x == 1 and y == 10:\n",
    "    print('x = 1 and y = 10')\n",
    "\n",
    "if x == 1 and y > 10:\n",
    "    print('x = 1 and y > 10')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "80a48050",
   "metadata": {},
   "source": [
    "Παράδειγμα"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "fb8fcdf9",
   "metadata": {},
   "outputs": [],
   "source": [
    "#y = 2\n",
    "#y = 15\n",
    "y = 5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "9c2ebef4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "s = 0\n",
    "x = 5\n",
    "\n",
    "if x == y:\n",
    "    s = s + 1\n",
    "\n",
    "if x >= y:\n",
    "    s = s + 1\n",
    "else:\n",
    "    s = s + 10\n",
    "\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "24c97c72",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "s = 0\n",
    "x = 5\n",
    "\n",
    "if x == y:\n",
    "    s = s + 1\n",
    "elif x >= y:\n",
    "    s = s + 1\n",
    "else:\n",
    "    s = s + 10\n",
    "\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "77bb0690",
   "metadata": {},
   "source": [
    "Άσκηση 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ae54eb9",
   "metadata": {},
   "outputs": [],
   "source": [
    "T_str = input('Give me temperature')\n",
    "T = float(T_str)\n",
    "\n",
    "S = T > 23.0\n",
    "\n",
    "if S:\n",
    "    print(\"It's hot\")\n",
    "else:\n",
    "    print(\"It's cold\")\n",
    "\n",
    "# Εναλλακτική λύση\n",
    "\n",
    "if T > 23.0:\n",
    "    print(\"It's hot\")\n",
    "else:\n",
    "    print(\"It's cold\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "97f17951",
   "metadata": {},
   "source": [
    "Άσκηση 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4e9db647",
   "metadata": {},
   "outputs": [],
   "source": [
    "age = 20\n",
    "\n",
    "if age < 25 or age >=65:\n",
    "print(\"Reduced-fare ticket: 0.50 euro\")\n",
    "    else:\n",
    "        print(\"Adult ticket: 1.20 euro\")\n",
    "    print(\"Thank you!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bfcadc74",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Διόρθωση identation\n",
    "age = 47\n",
    "\n",
    "if age < 25 or age >=65:\n",
    "    print(\"Reduced-fare ticket: 0.50 euro\")\n",
    "else:\n",
    "    print(\"Adult ticket: 1.20 euro\")\n",
    "print(\"Thank you!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f605ed93",
   "metadata": {},
   "source": [
    "Άσκηση 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "1e1319b9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "T >= 15\n"
     ]
    }
   ],
   "source": [
    "# Διορθώστε τον ακόλουθο κώδικα ώστε το Τ να τυπώνεται στο κατάλληλο διάστημα \n",
    "\n",
    "T = 40\n",
    "\n",
    "if T >= 15:\n",
    "    print(\"T >= 15\")\n",
    "elif T > 30:\n",
    "    print(\"T > 30\")\n",
    "elif T > 80:\n",
    "    print(\"T > 80\")\n",
    "else:\n",
    "    print(\"T < 15\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "20456f05",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "T > 30\n"
     ]
    }
   ],
   "source": [
    "# Διόρθωση\n",
    "T = 40\n",
    "\n",
    "if T > 80:\n",
    "    print(\"T > 80\")\n",
    "elif T > 30:\n",
    "    print(\"T > 30\")\n",
    "elif T >= 15:\n",
    "    print(\"T >= 15\")\n",
    "else:\n",
    "    print(\"T < 15\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
