{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e4fbe266-9ec8-4dbd-9c5a-4f55c5675834",
   "metadata": {},
   "source": [
    "# Lesson 05 Demonstration\n",
    "\n",
    "## 1. Conditionals\n",
    "\n",
    "### 1.1. `if`, `else` & `elif`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "548f3d54-6b50-4714-9cf6-5f1cb7fbb22b",
   "metadata": {},
   "outputs": [],
   "source": [
    "num = 0\n",
    "\n",
    "if num > 0:\n",
    "    print('Greater than zero')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "309ae46e-ae10-493b-bbac-092c49325662",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not greater than zero\n"
     ]
    }
   ],
   "source": [
    "if num > 0:\n",
    "    print('Greater than zero')\n",
    "    \n",
    "else:\n",
    "    print('Not greater than zero')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c10cc4a2-ffbb-441e-a42b-4036ac220c54",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Equal to zero\n"
     ]
    }
   ],
   "source": [
    "if num > 0:\n",
    "    print('Greater than zero')\n",
    "    \n",
    "elif num == 0:\n",
    "    print('Equal to zero')\n",
    "    \n",
    "else:\n",
    "    print('Not greater than zero')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b792047c-6c31-49ae-ae99-b17c8954e5bd",
   "metadata": {},
   "source": [
    "### 1.2. Nested conditionals"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "ae7a194c-6989-47b6-8a9a-8969c0aff3b4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Equal to zero\n"
     ]
    }
   ],
   "source": [
    "num = 0\n",
    "\n",
    "if num > 0:\n",
    "    if num % 2 == 0:\n",
    "        print('Positive even number')\n",
    "        \n",
    "    else:\n",
    "        print('Positive odd number')\n",
    "        \n",
    "elif num == 0:\n",
    "    print('Equal to zero')\n",
    "    \n",
    "else:\n",
    "    print('Negative number')\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cc55b76c-807f-4995-b851-d3f843c4b471",
   "metadata": {},
   "source": [
    "## 2. Loops\n",
    "\n",
    "### 2.1. `for` loop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c940fd7f-afd4-45b3-b806-df48fe9e8461",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Python\n",
      "is\n",
      "awesome\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "my_list = ['Python', 'is', 'awesome']\n",
    "\n",
    "for word in my_list:\n",
    "    print(word)\n",
    "    the_loop_ran = True\n",
    "    \n",
    "print(the_loop_ran)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ca80678f-dda4-4c21-9141-feb3264b44be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Count is: 0\n",
      "Count is: 1\n",
      "Count is: 2\n",
      "Count is: 3\n",
      "Count is: 4\n",
      "Done\n"
     ]
    }
   ],
   "source": [
    "count = 0\n",
    "\n",
    "while count < 5:\n",
    "    print(f\"Count is: {count}\")\n",
    "    count += 1\n",
    "\n",
    "print('Done')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4b15612-c8b0-4f61-aa1f-acc5195def13",
   "metadata": {},
   "source": [
    "### 2.2. `range()` and enumeration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6a0b646d-e9f0-4b28-91df-302d937e4c5d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "49e69264-019f-43c3-b0ca-70816ee78970",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n",
      "12\n",
      "11\n",
      "10\n",
      "9\n",
      "8\n",
      "7\n",
      "6\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for i in range(13,4,-1):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "09b8c402-265d-432f-a3b4-cd2840c6d142",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Word 0 is Python\n",
      "Word 1 is is\n",
      "Word 2 is awesome\n"
     ]
    }
   ],
   "source": [
    "my_list = ['Python', 'is', 'awesome']\n",
    "\n",
    "for i, word in enumerate(my_list):\n",
    "    print(f'Word {i} is {word}')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 [3.10]",
   "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.10.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
