From 36ab9a863ad2d343f7e7a6e0e92940f4dce8dd6b Mon Sep 17 00:00:00 2001 From: Nilanjana Habisyasi <65666492+mnilanjana@users.noreply.github.com> Date: Mon, 24 Aug 2020 16:42:30 +0530 Subject: [PATCH] Created using Colaboratory --- assignment1.ipynb | 845 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 845 insertions(+) create mode 100644 assignment1.ipynb diff --git a/assignment1.ipynb b/assignment1.ipynb new file mode 100644 index 0000000..85b9ab7 --- /dev/null +++ b/assignment1.ipynb @@ -0,0 +1,845 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "assignment1.ipynb", + "provenance": [], + "collapsed_sections": [], + "authorship_tag": "ABX9TyNe9oc2pxvOBY1FFUC/aS6J", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "p_qoE9PELLZv", + "colab_type": "text" + }, + "source": [ + "" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "uwO4Uv4VLNuK", + "colab_type": "text" + }, + "source": [ + "assignment\n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "YotrPObVLQJf", + "colab_type": "code", + "colab": {} + }, + "source": [ + "import numpy as np" + ], + "execution_count": 180, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "NnHgoN0nLV4O", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 203 + }, + "outputId": "7d785da8-4ecc-4786-f9be-3f7ba470ace8" + }, + "source": [ + "a=[1,2,3,4,5]\n", + "a=np.array([1,2,3,4,5])\n", + "print(a)" + ], + "execution_count": 181, + "outputs": [ + { + "output_type": "error", + "ename": "TypeError", + "evalue": "ignored", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: 'list' object is not callable" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "3SGhe1pGLiKZ", + "colab_type": "code", + "colab": {} + }, + "source": [ + "list1=[1,2,3]\n", + "list2=[4,5,6]\n", + "list3=[7,8,9]" + ], + "execution_count": 179, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "FSb12R3DNUfe", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 70 + }, + "outputId": "f1322550-98a1-4387-f9fd-516e565f139b" + }, + "source": [ + "matrix2 = np.matrix([list1,list2,list3])\n", + "matrix2" + ], + "execution_count": 178, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "matrix([[1, 2, 3],\n", + " [4, 5, 6],\n", + " [7, 8, 9]])" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 178 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "U_KZLgcBOIt0", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "400b9a49-3160-42f5-80dd-47f00eecaf16" + }, + "source": [ + "matrix2.shape" + ], + "execution_count": 177, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(3, 3)" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 177 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "RNwuMIwBPgeP", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 185 + }, + "outputId": "61e36990-2cc1-4ab7-e6e6-e46b0de89097" + }, + "source": [ + "matrix2=np.array([list1,list2,list3])\n", + "print(matrix2)" + ], + "execution_count": 176, + "outputs": [ + { + "output_type": "error", + "ename": "TypeError", + "evalue": "ignored", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmatrix2\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mlist1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlist2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlist3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmatrix2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: 'list' object is not callable" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "9G3-k-snV8b8", + "colab_type": "code", + "colab": {} + }, + "source": [ + "\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "Tsp9al-7T9Hp", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "e401c586-1e80-4b00-eab1-3ccfd6187ac8" + }, + "source": [ + "start, end = 1, 17\n", + " \n", + "# iterating each number in list \n", + "for num in range(start, end + 1): \n", + " \n", + " # checking condition \n", + " if num % 2 != 0: \n", + " print(num, end = \" \") \n", + "\n" + ], + "execution_count": 173, + "outputs": [ + { + "output_type": "stream", + "text": [ + "1 3 5 7 9 11 13 15 17 " + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "VA_KfnikUZdI", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 185 + }, + "outputId": "5f41db5a-2ac2-4afc-f194-2cf0f76d490f" + }, + "source": [ + "list=([1,3,5,7,9,11,13,15,17])\n", + "arr2 = np.arange(list).reshape(3,3)" + ], + "execution_count": 172, + "outputs": [ + { + "output_type": "error", + "ename": "TypeError", + "evalue": "ignored", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m7\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m9\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m11\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m13\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m15\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m17\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0marr2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'list' and 'int'" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "HqajGu-bYEMn", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 203 + }, + "outputId": "99aabe38-55f9-4930-e37f-8e9bd6d8245d" + }, + "source": [ + "n = 3\n", + "p = 3\n", + "np.array([[(i+j)%2 for i in range(n)] for j in range(p)])" + ], + "execution_count": 171, + "outputs": [ + { + "output_type": "error", + "ename": "TypeError", + "evalue": "ignored", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m%\u001b[0m\u001b[0;36m2\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m: 'list' object is not callable" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "i-nGCM1kaPOY", + "colab_type": "code", + "colab": {} + }, + "source": [ + "list4=[1,3,5]\n", + "list5=[7,9,11]\n", + "list6=[13,15,17]" + ], + "execution_count": 170, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "s_LRYO_Sa95h", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 70 + }, + "outputId": "3ba60474-608f-4230-deba-6432fa061ee2" + }, + "source": [ + "matrix3 = np.matrix([list4,list5,list6])\n", + "matrix3" + ], + "execution_count": 169, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "matrix([[ 1, 3, 5],\n", + " [ 7, 9, 11],\n", + " [13, 15, 17]])" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 169 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "D03O-oBubEk2", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "d94b11d7-afaf-471b-e418-e9ecedc1f24d" + }, + "source": [ + "matrix3.shape" + ], + "execution_count": 168, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "(3, 3)" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 168 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "2wTqE9-_bIQS", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 70 + }, + "outputId": "4acdc1ca-e22f-4644-faa4-86f654474784" + }, + "source": [ + "arr2 = np.arange(1,10).reshape(3,3)\n", + "arr2" + ], + "execution_count": 167, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "array([[1, 2, 3],\n", + " [4, 5, 6],\n", + " [7, 8, 9]])" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 167 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "x1s-qmf4bhYr", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 203 + }, + "outputId": "dad57c70-3860-4adc-9d2d-9b82faa55428" + }, + "source": [ + "arr = np.array([1, 2, 3, 4, 5])\n", + "print(arr)\n", + "np.reshape(arr,(5,1))" + ], + "execution_count": 166, + "outputs": [ + { + "output_type": "error", + "ename": "TypeError", + "evalue": "ignored", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0marr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m5\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marr\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: 'list' object is not callable" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "g9yB0brtdtAN", + "colab_type": "code", + "colab": {} + }, + "source": [ + "arr.shape" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "MrvY8Z1Sezgw", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "eeb5fa41-fbcc-4624-e8df-9b83d43d6e2e" + }, + "source": [ + "arr1 = np.array=([1,2,5,6,3,8,9,4,2,6])\n", + "arr1\n", + "print(np.array)" + ], + "execution_count": 165, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[1, 2, 5, 6, 3, 8, 9, 4, 2, 6]\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "d3PdNgK9fdJh", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "12b43a75-f3a0-41fc-c201-051f76c39e18" + }, + "source": [ + "arr1[3]" + ], + "execution_count": 161, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "6" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 161 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "SD2W0qZvfyza", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "4487e73c-f9b8-47be-999b-b0e8b9ccd4a1" + }, + "source": [ + "arr1[4]" + ], + "execution_count": 162, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "3" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 162 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "_9PxRpjxgiyY", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "d724bbc2-5d8c-48f8-dbe0-a0aeb5696b6f" + }, + "source": [ + "arr1[9]" + ], + "execution_count": 163, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "6" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 163 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "2Xjl9jnXhJua", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "245a8d07-988c-414d-e4e8-b3986831b6a4" + }, + "source": [ + "arr1[-1]" + ], + "execution_count": 164, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "6" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 164 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "colab_type": "code", + "id": "sRIK2m5guAVB", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 221 + }, + "outputId": "7bcf5143-991f-45b9-ecb7-917702a46055" + }, + "source": [ + "arr1 = np.array=([1,2,5,6,3,8,9,4,2,6])\n", + "arr1\n", + "arr1[-3:]=100\n", + "arr1" + ], + "execution_count": 160, + "outputs": [ + { + "output_type": "error", + "ename": "TypeError", + "evalue": "ignored", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0marr1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m8\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m9\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0marr1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0marr1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m100\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0marr1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: can only assign an iterable" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "c0yezcRCnvSh", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 105 + }, + "outputId": "00f3dd0b-80c4-4be3-deb3-e747656da571" + }, + "source": [ + "arr3 = np.arange(0,25).reshape(5,5)\n", + "arr3" + ], + "execution_count": 157, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "array([[ 0, 1, 2, 3, 4],\n", + " [ 5, 6, 7, 8, 9],\n", + " [10, 11, 12, 13, 14],\n", + " [15, 16, 17, 18, 19],\n", + " [20, 21, 22, 23, 24]])" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 157 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "UV15i3Qr1GIL", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 167 + }, + "outputId": "e05fefbf-b32c-4973-ed7f-76fd94c5d616" + }, + "source": [ + "" + ], + "execution_count": 158, + "outputs": [ + { + "output_type": "error", + "ename": "IndexError", + "evalue": "ignored", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0marr3\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m: too many indices for array" + ] + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "v3889epupFF6", + "colab_type": "code", + "colab": {} + }, + "source": [ + "arr3[3]\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "q_gO1HOdpMdY", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "c3bde998-2c7a-4853-b378-f1ef3833948e" + }, + "source": [ + "arr3[2]" + ], + "execution_count": 155, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "array([21, 23, 25, 27, 29])" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 155 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "7hOmFsQdvN4K", + "colab_type": "code", + "colab": {} + }, + "source": [ + "" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "Noz5Sf3ypQsg", + "colab_type": "code", + "colab": {} + }, + "source": [ + "\n", + "\n", + "\n", + "\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab_type": "code", + "id": "w3hlmGC6GtcX", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 158 + }, + "outputId": "dd74e63e-a189-423d-babe-68b67fe21efb" + }, + "source": [ + "#5*5 natrix\n", + "arr3=np.arange(1,51,2).reshape(5,5)\n", + "print(repr(arr3))\n", + "\n", + "print(arr3[1:4,1:4])\n", + "\n", + "\n" + ], + "execution_count": 154, + "outputs": [ + { + "output_type": "stream", + "text": [ + "array([[ 1, 3, 5, 7, 9],\n", + " [11, 13, 15, 17, 19],\n", + " [21, 23, 25, 27, 29],\n", + " [31, 33, 35, 37, 39],\n", + " [41, 43, 45, 47, 49]])\n", + "[[13 15 17]\n", + " [23 25 27]\n", + " [33 35 37]]\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "colab_type": "code", + "id": "qsbx12-lGdqV", + "colab": {} + }, + "source": [ + "\n", + "\n", + "\n", + "\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "2Vso95MVGbzp", + "colab_type": "code", + "colab": {} + }, + "source": [ + "" + ], + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file