{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "KAcFIgSGVudj"
   },
   "source": [
    "## Comments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "tzL-1yAGVt0E"
   },
   "outputs": [],
   "source": [
    "# This is a comment\n",
    "\n",
    "\"\"\"This is a \n",
    "    multiline\n",
    "    comment.\"\"\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "Nlow26HbQEc5"
   },
   "source": [
    "## Variables and Types\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 632,
     "status": "ok",
     "timestamp": 1550135633356,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "iO--U-tJQLxX",
    "outputId": "cf185cb9-2e1e-4fec-a8ed-eda7902e0506"
   },
   "outputs": [],
   "source": [
    "coolvar = 7 # declaration\n",
    "coolvar # almost the same as print(myvar)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 667,
     "status": "ok",
     "timestamp": 1550137939273,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "7o9umUvSShfb",
    "outputId": "af32d537-60b1-4146-aa9b-bfbb8ea31e19"
   },
   "outputs": [],
   "source": [
    "print(7, type(7)) # integer\n",
    "print(float(7), type(7.0)) # float"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 85
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 535,
     "status": "ok",
     "timestamp": 1550137988872,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "GriCYbfqR1mI",
    "outputId": "005dd4db-8577-4e48-86a6-a8a2ab1b4827"
   },
   "outputs": [],
   "source": [
    "# ALL these are strings\n",
    "\n",
    "print(\"Let's go\", type(\"Let's go\")) # you can also escape \\' when in single quotes\n",
    "\n",
    "print('\"To be or not to be?\"', type(\"'To be or not to be?'\"))\n",
    "\n",
    "a = \"\"\"This is a multiline \n",
    "string\"\"\"\n",
    "print(a, type(a))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "J3oYLxUBVUUA"
   },
   "source": [
    "## Operators"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 136
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 621,
     "status": "ok",
     "timestamp": 1550138517776,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "XMPs8292SH3l",
    "outputId": "68092a7d-86ac-4b94-a32e-f84ecdcbfbb7"
   },
   "outputs": [],
   "source": [
    "a = 73\n",
    "b = 42\n",
    "\n",
    "# addition\n",
    "print('a + b =', a + b)\n",
    "\n",
    "# subtraction\n",
    "print('a - b =', a - b)\n",
    "\n",
    "# multiplication\n",
    "print('a * b =', a * b)\n",
    "\n",
    "# classic division - returns a float\n",
    "print('a / b =', a / b)\n",
    "\n",
    "# floor division - discards the fractional part\n",
    "print('a // b =', a // b)\n",
    "\n",
    "# remainder of the division\n",
    "print('a % b =', a % b)\n",
    "\n",
    "# power (a^2)\n",
    "print('a ** 2 =', a ** 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 102
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 543,
     "status": "ok",
     "timestamp": 1550242925732,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "iz_7UNjsfT0O",
    "outputId": "6bbf8d57-378f-4061-a942-3b1774f35388"
   },
   "outputs": [],
   "source": [
    "print(2 < 5)\n",
    "print(4 > 10)\n",
    "print(3 >= 3)\n",
    "print(5 == 6)\n",
    "print(6 != 9)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "vgzS6HVOW_yN"
   },
   "source": [
    "## Implicit Type Conversion - only for some types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 717,
     "status": "ok",
     "timestamp": 1550136936096,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "C678rRnGVamt",
    "outputId": "d03fce44-8ddf-4eb2-bfa8-65620963f367"
   },
   "outputs": [],
   "source": [
    "num_int = 123  # integer type\n",
    "num_flo = 1.23 # float type\n",
    "num_int + num_flo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 198
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 768,
     "status": "error",
     "timestamp": 1550136970008,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "v3Dk7igwXINK",
    "outputId": "4b582150-af85-47dd-b955-f07df7c2c23c"
   },
   "outputs": [],
   "source": [
    "num_int = 123     # int type\n",
    "num_str = \"456\"   # str type\n",
    "\n",
    "num_int+num_str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 164
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 865,
     "status": "error",
     "timestamp": 1550243989240,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "uE6wGB0SXQdX",
    "outputId": "69b37bb4-ffaf-443d-d485-d60eb787dd02"
   },
   "outputs": [],
   "source": [
    "str(num_int) + num_str"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "MbH0WNmPXbYw"
   },
   "source": [
    "## Data Structures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "a5YxX-BNXQ9J"
   },
   "outputs": [],
   "source": [
    "my_list = [] # empty list\n",
    "my_list = [1, 2, 3] # list of integers\n",
    "my_list = [1, \"Hello\", 3.4] # list with mixed data types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 620,
     "status": "ok",
     "timestamp": 1550242962287,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "2_1OAWuXXpPS",
    "outputId": "7d9594a7-eb86-44eb-cf88-26c96cb587a9"
   },
   "outputs": [],
   "source": [
    "print(my_list[0]) # Accessing first element"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 102
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 599,
     "status": "ok",
     "timestamp": 1550242976699,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "dn5Q_h4ifu6X",
    "outputId": "e5ce5a03-865c-42bc-98f1-ebba619ef343"
   },
   "outputs": [],
   "source": [
    "print(my_list[:])\n",
    "print(my_list[0:2])\n",
    "print(my_list[-3:-1])\n",
    "print(my_list[1:])\n",
    "print(my_list[::2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "RdxktQYuX3RA"
   },
   "outputs": [],
   "source": [
    "language = (\"French\", \"German\", \"English\", \"Polish\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "5IOT50dNYFu_"
   },
   "outputs": [],
   "source": [
    "str = 'this is a string'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "2_trBMfUYKlp"
   },
   "outputs": [],
   "source": [
    "# set of integers\n",
    "my_set = set()\n",
    "my_set = {1, 2, 3}\n",
    "print(my_set)\n",
    "\n",
    "# set of mixed datatypes\n",
    "my_set = {1.0, \"Hello\", (1, 2, 3)}\n",
    "print(my_set)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "7PKZ3pOvYNOC"
   },
   "outputs": [],
   "source": [
    "# set of integers\n",
    "my_set = {1, 2, 3}\n",
    "\n",
    "my_set.add(4)\n",
    "print(my_set) # Output: {1, 2, 3, 4}\n",
    "\n",
    "my_set.add(2)\n",
    "print(my_set) # Output: {1, 2, 3, 4}\n",
    "\n",
    "my_set.update([3, 4, 5])\n",
    "print(my_set) # Output: {1, 2, 3, 4, 5}\n",
    "\n",
    "my_set.remove(4)\n",
    "print(my_set) # Output: {1, 2, 3, 5}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 636,
     "status": "ok",
     "timestamp": 1550243081740,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "1i1HIoU1YOAi",
    "outputId": "af8d740e-ad17-4d69-cf65-86b33d8e6909"
   },
   "outputs": [],
   "source": [
    "# empty dictionary\n",
    "my_dict = {}\n",
    "\n",
    "# dictionary with integer keys\n",
    "my_dict = {1: 'apple', 2: 'ball'}\n",
    "\n",
    "# dictionary with mixed keys\n",
    "my_dict = {'name': 'John', 1: [2, 4, 3]}\n",
    "\n",
    "person = {'name':'Jack', 'age': 26, 'salary': 4534.2}\n",
    "print(person['age'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "TrT8c4lvYfDi"
   },
   "source": [
    "## Python Control Flow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 605,
     "status": "ok",
     "timestamp": 1550243112681,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "LWu3EdEzYlQT",
    "outputId": "fadf92e0-667c-479f-8170-bb4f8a3ade13"
   },
   "outputs": [],
   "source": [
    "num = -1\n",
    "\n",
    "if num > 0:\n",
    "    print(\"Positive number\")\n",
    "elif num == 0:\n",
    "    print(\"Zero\")\n",
    "else:\n",
    "    print(\"Negative number\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 660,
     "status": "ok",
     "timestamp": 1550243121487,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "jOOgcC6QYlYI",
    "outputId": "75e0ebc5-743b-423a-cb12-f9229a1e1c6e"
   },
   "outputs": [],
   "source": [
    "if False:\n",
    "    print(\"I am inside the body of if.\")\n",
    "    print(\"I am also inside the body of if.\")\n",
    "print(\"I am outside the body of if\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 713,
     "status": "ok",
     "timestamp": 1550243136184,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "A2KmIm9WYren",
    "outputId": "d3941ea3-4a91-4251-862a-4645561a3a0b"
   },
   "outputs": [],
   "source": [
    "n = 100\n",
    "\n",
    "# initialize sum and counter\n",
    "sum = 0\n",
    "i = 1\n",
    "\n",
    "while i <= n:\n",
    "    sum = sum + i\n",
    "    i = i+1    # update counter\n",
    "\n",
    "print(\"The sum is\", sum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1380,
     "status": "ok",
     "timestamp": 1550312653473,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "T3h2O_H0YvjL",
    "outputId": "8d087c59-fd45-4fd1-fce9-7206901edb12"
   },
   "outputs": [],
   "source": [
    "numbers = [6, 5, 3, 8, 4, 2]\n",
    "\n",
    "sum = 0\n",
    "\n",
    "# iterate over the list\n",
    "for val in numbers:\n",
    "    sum = sum+val\n",
    "\n",
    "print(\"The sum is\", sum) # Output: The sum is 28"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "RSx8bEeGY-em"
   },
   "source": [
    "## Functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "CblmESbFY_5N"
   },
   "outputs": [],
   "source": [
    "def print_lines():\n",
    "    print(\"I am line1.\")\n",
    "    print(\"I am line2.\")\n",
    "\n",
    "# function call\n",
    "print_lines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 643,
     "status": "ok",
     "timestamp": 1550243195838,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "PNUDukNVZCWH",
    "outputId": "a250269b-540f-474f-8377-1f6584a47d13"
   },
   "outputs": [],
   "source": [
    "def add_numbers(a, b):\n",
    "    sum = a + b\n",
    "    return sum\n",
    "\n",
    "result = add_numbers(4, 5)\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 462,
     "status": "ok",
     "timestamp": 1550243196240,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "UPGHkS8gadiP",
    "outputId": "7b7fa13f-af34-441f-a73b-32d593f70f49"
   },
   "outputs": [],
   "source": [
    "def greet(name, msg = \"Good morning!\"):\n",
    "    \"\"\"\n",
    "    This function greets to\n",
    "    the person with the\n",
    "    provided message.\n",
    "\n",
    "    If message is not provided,\n",
    "    it defaults to \"Good\n",
    "    morning!\"\n",
    "    \"\"\"\n",
    "\n",
    "    print(\"Hello\",name + ', ' + msg)\n",
    "\n",
    "greet(\"Kate\")\n",
    "greet(\"Bruce\",\"How do you do?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 85
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 397,
     "status": "ok",
     "timestamp": 1550243196580,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "zS1C6PiGagdv",
    "outputId": "7e33eb1d-aa84-4843-c84c-10ff758de61b"
   },
   "outputs": [],
   "source": [
    "def greet(*names):\n",
    "    \"\"\"This function greets all\n",
    "    the person in the names tuple.\"\"\"\n",
    "\n",
    "    # names is a tuple with arguments\n",
    "    for name in names:\n",
    "        print(\"Hello\",name)\n",
    "\n",
    "greet(\"Monica\",\"Luke\",\"Steve\",\"John\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "oRndJAmSZh0X"
   },
   "source": [
    "## Python OOP"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 690,
     "status": "ok",
     "timestamp": 1550243225884,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "aQD_VdBiZjb2",
    "outputId": "e9f4b4f1-3a94-4320-df9d-03ec9989bbc5"
   },
   "outputs": [],
   "source": [
    "class ComplexNumber:\n",
    "    def __init__(self,r = 0,i = 0):  # constructor\n",
    "        self.real = r\n",
    "        self.imag = i\n",
    "\n",
    "    def getData(self):\n",
    "        print(\"{0}+{1}j\".format(self.real,self.imag))\n",
    "\n",
    "\n",
    "c1 = ComplexNumber(2,3) # Create a new ComplexNumber object\n",
    "c1.getData()\n",
    "\n",
    "c2 = ComplexNumber() # Create a new ComplexNumber object\n",
    "c2.getData()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "8qb4YZh0Z6Zh"
   },
   "source": [
    "## List Comprehension vs For Loop in Python\n",
    "\n",
    "[expression for item in list]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 623,
     "status": "ok",
     "timestamp": 1550243251409,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "AlKqP3UFZ7rx",
    "outputId": "dac09b26-c83a-478e-df8b-cb74a2c28eb7"
   },
   "outputs": [],
   "source": [
    "h_letters = []\n",
    "\n",
    "for letter in 'human':\n",
    "    h_letters.append(letter)\n",
    "\n",
    "print(h_letters)\n",
    "\n",
    "h_letters = [letter for letter in 'human']\n",
    "print( h_letters)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 442,
     "status": "ok",
     "timestamp": 1550243252658,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "K1dLv7EkaMtp",
    "outputId": "4c5e8851-271a-4439-8406-f438b1218272"
   },
   "outputs": [],
   "source": [
    "number_list = [ x for x in range(20) if x % 2 == 0]\n",
    "print(number_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 591,
     "status": "ok",
     "timestamp": 1550243254108,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "eTa-JIz_aUov",
    "outputId": "b10158df-42f9-4e0a-f440-cf9623c77f19"
   },
   "outputs": [],
   "source": [
    "matrix = [[1, 2], [3,4], [5,6], [7,8]]\n",
    "transpose = [[row[i] for row in matrix] for i in range(2)]\n",
    "print (transpose)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "yGQXct_oYaDQ"
   },
   "source": [
    "## Miscelanneous"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 611,
     "status": "ok",
     "timestamp": 1550243286747,
     "user": {
      "displayName": "Pepa Atanasova",
      "photoUrl": "https://lh6.googleusercontent.com/-Z_n_MgibMtM/AAAAAAAAAAI/AAAAAAAAI7U/25hdP8CdNHE/s64/photo.jpg",
      "userId": "09251033333050931776"
     },
     "user_tz": -120
    },
    "id": "eQgskPUCYcVI",
    "outputId": "8f68ca1e-75f3-4cad-f455-720a60e39e92"
   },
   "outputs": [],
   "source": [
    "list(range(1, 10))"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "name": "2_2_python_intro.ipynb",
   "provenance": [],
   "version": "0.3.2"
  },
  "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.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}