Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 81 additions & 30 deletions Kaushal2612.ipynb
Original file line number Diff line number Diff line change
@@ -1,32 +1,83 @@
{
"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": "Kaushal2612.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": "11-2L_m7oAu9",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"# -*- coding: utf-8 -*-\n",
"\"\"\"Numpy_Exercises.ipynb\n",
"\n",
"Automatically generated by Colaboratory.\n",
"\n",
"Original file is located at\n",
" https://colab.research.google.com/drive/1Ho1yNgI2o5vXAly5PH2vv0UKOFNgpaeU\n",
"\n",
"# Numpy Exercises\n",
"\n",
"1) Create a uniform subdivision of the interval -1.3 to 2.5 with 64 subdivisions\n",
"\"\"\"\n",
"\n",
"import numpy as np #import numpy\n",
"b = np.linspace(-1.3,2.5, num=64)\n",
"\n",
"\n",
"\"\"\"2) Generate an array of length 3n filled with the cyclic pattern 1, 2, 3\"\"\"\n",
"x = np.array([1.0, 2.0, 3.0])\n",
"n=5\n",
"y = np.resize(x, 3*n)\n",
"\n",
"\n",
"\"\"\"3) Create an array of the first 10 odd integers.\"\"\"\n",
"a = np.array([1,3,5,7,9,11,13,15,17,19])\n",
"\n",
"\n",
"\"\"\"4) Find intersection of a and b\"\"\"\n",
"\n",
"#expected output array([2, 4])\n",
"a = np.array([1,2,3,2,3,4,3,4,5,6])\n",
"b = np.array([7,2,10,2,7,4,9,4,9,8])\n",
"np.intersect1d(a, b)\n",
"\n",
"\"\"\"5) Reshape 1d array a to 2d array of 2X5\"\"\"\n",
"\n",
"a = np.arange(10)\n",
"a.reshape(2,5)\n",
"\n",
"\"\"\"6) Create a numpy array to list and vice versa\"\"\"\n",
"\n",
"a = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
"a.tolist()\t#convert nparray to list\n",
"a = np.array(a)\n",
"\n",
"\"\"\"7) Create a 10 x 10 arrays of zeros and then \"frame\" it with a border of ones.\"\"\"\n",
"a = np.ones((10,10))\n",
"a[1:-1,1:-1] = 0\n",
"\n",
"\"\"\"8) Create an 8 x 8 array with a checkerboard pattern of zeros and ones using a slicing+striding approach.\"\"\"\n",
"a = np.zeros((8, 8), dtype = int)\n",
"a[1::2, ::2] = 1\n",
"a[::2, 1::2] = 1\n"
],
"execution_count": 0,
"outputs": []
}
]
}