{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Your Student ID:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 6204640087"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Question 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# This task, you want to find out Today's date by using the library time\n",
    "\n",
    "Hint: Use time.FUNC_NAME.FUNC_NAME? (where FUNC_NAME is replaced with the function you found) to see information about that function and then call the function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=8, tm_mday=23, tm_hour=10, tm_min=59, tm_sec=11, tm_wday=1, tm_yday=235, tm_isdst=0)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time as t\n",
    "\n",
    "t.localtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Question  2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.1 What is the standard deviation of the data:\n",
    "\n",
    "Hint: Using the function std in library Numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = [1,3,1,2,9,4,5,6,10,4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.9410882339705484"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "np.std(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.2 Then, you have the additional data as shown below"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "add_data =[8,11,2,5,6,4,3,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Add the new data to the original data, then re-calculate the standard deviation again."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.954385733401851"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.extend(add_data)\n",
    "np.std(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 3, 1, 2, 9, 4, 5, 6, 10, 4, 8, 11, 2, 5, 6, 4, 3, 2]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Question 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Consider the below information:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "data ={'Year':'2021','transactional data':{\n",
    " 'transaction_id': 1000001,\n",
    " 'source_country': 'United Kingdom',\n",
    " 'target_country': 'Italy',\n",
    " 'send_currency': 'GBP',\n",
    " 'send_amount': 'GBP1000.00',\n",
    " 'target_currency': 'EUR',\n",
    " 'fx_rate EUR/GBP': 1.1648674,\n",
    " 'fee_pct': 0.50, \n",
    " 'platform': 'mobile'}}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.1 Using the python code to pick up the foreign exchange rate  ('fx_rate EUR/GBP') from this dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Year', 'transactional data']"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(data.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.1648674"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['transactional data']['fx_rate EUR/GBP']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.2 You now need to include the data for the \"fee_amount,\" which can be determined from the funds you send to the target country (send_amount) multiplied by the fee percentage (fee_pct). \n",
    "\n",
    "Create the new keyword \"fee_amount\" for this dataset, and then report its value.\n",
    "\n",
    "Hint: using replace() and float() to convert the 'send_amount' into a number.Then, multiply with fee percentage."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "fee_amount= float(data['transactional data']['send_amount'].replace('GBP',\"\"))*data['transactional data']['fee_pct']\n",
    "more_data = {\"fee_amount\":fee_amount}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "data.update(more_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Year': '2021',\n",
       " 'transactional data': {'transaction_id': 1000001,\n",
       "  'source_country': 'United Kingdom',\n",
       "  'target_country': 'Italy',\n",
       "  'send_currency': 'GBP',\n",
       "  'send_amount': 'GBP1000.00',\n",
       "  'target_currency': 'EUR',\n",
       "  'fx_rate EUR/GBP': 1.1648674,\n",
       "  'fee_pct': 0.5,\n",
       "  'platform': 'mobile'},\n",
       " 'fee_amount': 500.0}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The fee amount is 500.0\n"
     ]
    }
   ],
   "source": [
    "print(f\"The fee amount is {data['fee_amount']}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
