Skip to content
Open
59 changes: 29 additions & 30 deletions Anubhab-Bob.ipynb
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Anubhab-Bob.ipynb",
"version": "0.3.2",
"provenance": []
},
"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.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"cells": [
{
"metadata": {
"id": "A5gF9gMFq3Ck",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}
298 changes: 298 additions & 0 deletions Anubhab_Bob_Assignment_2_Lists.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Anubhab_Bob (1).ipynb",
"version": "0.3.2",
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"[View in Colaboratory](https://colab.research.google.com/github/Anubhab-Bob/Assignment-2/blob/Anubhab-Bob/Anubhab_Bob_Assignment_2_Lists.ipynb)"
]
},
{
"metadata": {
"id": "A5gF9gMFq3Ck",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"dummy_list=[1, 2, 3, 4, 5, 3]"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "QkJs_byK_qPg",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "6517822b-da14-4727-f436-c101ba3ec661"
},
"cell_type": "code",
"source": [
"print(dummy_list)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"[1, 2, 3, 4, 5, 3]\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "F2QMHeQAB4Ja",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"print(sorted(dummy_list, reverse=True))"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "7XeXBwK6CD1i",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "3cefa005-b90a-4e72-8be7-24e06ea943fb"
},
"cell_type": "code",
"source": [
"dummy_list_2 = [2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n",
"dummy_list.extend(dummy_list_2)\n",
"print(dummy_list)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"[1, 2, 3, 4, 5, 3, 2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "ujmdan92Du6g",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"dummy_dict={}"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "TPaUVjDSEqyv",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"i=0\n",
"while i!= len(dummy_list):\n",
" if dummy_list[i] not in dummy_dict:\n",
" dummy_dict[dummy_list[i]]=1\n",
" else:\n",
" for key,value in dummy_dict.items():\n",
" if key == dummy_list[i]:\n",
" dummy_dict[key] = value + 1\n",
" break\n",
" #print(\"Key: \" + str(key))\n",
" #print (\"Value: \" + str(value))\n",
" i = i + 1\n",
" #print(i)"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "TY6jC_gyQbPP",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"for key, value in dummy_dict.items():\n",
" print(\"Key: \" + str(key))\n",
" print (\"Value: \" + str(value))\n",
" #print('\\n')"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "G0Ft30gsucvR",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 510
},
"outputId": "b3baa9d8-accc-4b8e-e76c-bd35a1052f3f"
},
"cell_type": "code",
"source": [
"for key in sorted(dummy_dict.keys()):\n",
" print (\"Key :\" + str(key) + '\\t\\t\\t' + \"Value :\" + str(dummy_dict[key]))\n",
"\n",
"print(\"\\n\\n\")\n",
"for key in sorted(dummy_dict.keys(), reverse=True):\n",
" print (\"Key :\" + str(key) + '\\t\\t\\t' + \"Value :\" + str(dummy_dict[key]))"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"Key :0\t\t\tValue :1\n",
"Key :1\t\t\tValue :2\n",
"Key :2\t\t\tValue :2\n",
"Key :3\t\t\tValue :2\n",
"Key :4\t\t\tValue :2\n",
"Key :5\t\t\tValue :1\n",
"Key :9.45\t\t\tValue :1\n",
"Key :12.01\t\t\tValue :1\n",
"Key :12.02\t\t\tValue :1\n",
"Key :16\t\t\tValue :1\n",
"Key :45.67\t\t\tValue :1\n",
"Key :90\t\t\tValue :1\n",
"Key :200\t\t\tValue :1\n",
"\n",
"\n",
"\n",
"Key :200\t\t\tValue :1\n",
"Key :90\t\t\tValue :1\n",
"Key :45.67\t\t\tValue :1\n",
"Key :16\t\t\tValue :1\n",
"Key :12.02\t\t\tValue :1\n",
"Key :12.01\t\t\tValue :1\n",
"Key :9.45\t\t\tValue :1\n",
"Key :5\t\t\tValue :1\n",
"Key :4\t\t\tValue :2\n",
"Key :3\t\t\tValue :2\n",
"Key :2\t\t\tValue :2\n",
"Key :1\t\t\tValue :2\n",
"Key :0\t\t\tValue :1\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "DtOAyHUtvm8Z",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "7414ec65-9a45-4354-fa7a-4e8e8370fde8"
},
"cell_type": "code",
"source": [
"x=200\n",
"dummy_list.remove(x)\n",
"print(dummy_list)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"[1, 2, 3, 4, 5, 3, 2, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "Adi6fYUBwnFG",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "ccced705-37e8-45c6-e5ba-a223ace45e16"
},
"cell_type": "code",
"source": [
"del dummy_list[5]\n",
"print (dummy_list)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"[1, 2, 3, 4, 5, 2, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "OTEasC7uxmOX",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "187e88b3-6f25-43ef-f133-ef3edc147094"
},
"cell_type": "code",
"source": [
"dummy_list.clear()\n",
"print(dummy_list)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"[]\n"
],
"name": "stdout"
}
]
}
]
}
Loading