{"id":9476,"date":"2016-02-02T17:17:37","date_gmt":"2016-02-02T22:17:37","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/ccpg1001\/?p=9476"},"modified":"2026-04-05T18:37:21","modified_gmt":"2026-04-05T23:37:21","slug":"s3eva2015tii_t3-funciones-matrices-rotar-extraer","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-s3eva20\/s3eva2015tii_t3-funciones-matrices-rotar-extraer\/","title":{"rendered":"s3Eva2015TII_T3 funciones matrices rotar, extraer"},"content":{"rendered":"\n<p><em><strong>Ejercicio<\/strong><\/em>: <a href=\"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-3eva20\/3eva2015tii_t3-funciones-matrices-rotar-extraer\/\" data-type=\"post\" data-id=\"2691\">3Eva2015TII_T3 funciones matrices rotar, extraer<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Algoritmo en Python<\/h2>\n\n\n\n<p><em><strong>Tarea<\/strong><\/em>: Integrar con tema 4<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# ICM00794-Fundamentos de Computaci\u00f3n - FCNM-ESPOL\n# 3Eva_IIT2015_T3 funciones matrices rotar, extraer\n# propuesta: edelros@espol.edu.ec\n# version con lazos y condicionales. \n# tarea: simplificar lazos con 'for'\n\nimport numpy as np\n\n# Tema 3 a)\ndef rotando(matriz,k):\n\n    #cuenta rotaciones\n    cuenta = 0    \n    while not(cuenta&gt;=k):\n        n,m = matriz.shape \n        tabla = numpy.zeros(shape=(m,n),dtype=int)\n\n        # inicia rotaci\u00f3n\n        i = 0 \n        while not(i&gt;=n):\n            j = 0\n            while not(j&gt;=m):\n                f = j\n                c = (n-1)-i\n                tabla&#x5B;f,c] = matriz&#x5B;i,j]\n                j = j + 1\n            i = i + 1\n        \n        matriz = np.copy(tabla)\n        cuenta = cuenta + 1\n    return(matriz)\n\n# Tema 3 b) funcion para extraer una esquina \n# de tama\u00f1o t de una matriz\n# k=0 ;esquina superior izquierda \n# k=1 ;esquina superior derecha\n# k=3 ;esquina inferior izquierda \n# k=2 ;esquina inferior derecha\n\ndef extraeresquina(matriz,k,t):\n    n,m = matriz.shape\n    esquina = np.zeros(shape=(t,t), dtype=int)\n    i = 0\n    while not(i&gt;=t):\n        j = 0\n        while not(j&gt;=t):\n            if (k==0):\n                f = i\n                c = j\n            if (k==1):\n                f = i\n                c = (m-t)+j\n            if (k==2):\n                f = (n-t)+i\n                c = (m-t)+j\n            if (k==3):\n                f = (n-t)+i\n                c = j\n            esquina&#x5B;i,j]=matriz&#x5B;f,c]\n            j = j+1\n        i = i+1   \n    return(esquina)\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Ejercicio: 3Eva2015TII_T3 funciones matrices rotar, extraer Algoritmo en Python Tarea: Integrar con tema 4<\/p>\n","protected":false},"author":8043,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"wp-custom-template-entrada-fp-ejemplos","format":"standard","meta":{"footnotes":""},"categories":[143],"tags":[58,157],"class_list":["post-9476","post","type-post","status-publish","format-standard","hentry","category-fp-s3eva20","tag-ejemplos-python","tag-fundamentos-programacion"],"_links":{"self":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/9476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/users\/8043"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/comments?post=9476"}],"version-history":[{"count":4,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/9476\/revisions"}],"predecessor-version":[{"id":23770,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/9476\/revisions\/23770"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/media?parent=9476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/categories?post=9476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/tags?post=9476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}