{"id":1939,"date":"2016-02-02T17:10:39","date_gmt":"2016-02-02T22:10:39","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/icm00794\/?p=1939"},"modified":"2026-04-05T18:38:02","modified_gmt":"2026-04-05T23:38:02","slug":"s3eva2015tii_t2-gestionar-mensajes-con-etiquetas","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-s3eva20\/s3eva2015tii_t2-gestionar-mensajes-con-etiquetas\/","title":{"rendered":"s3Eva2015TII_T2 Gestionar mensajes con etiquetas"},"content":{"rendered":"\n<p><em><strong>Ejercicio<\/strong><\/em>: <a href=\"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-3eva20\/3eva2015tii_t2-gestionar-mensajes-con-etiquetas\/\" data-type=\"post\" data-id=\"2689\">3Eva2015TII_T2 Gestionar mensajes con etiquetas<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Listas de dos dimensiones en Python\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/vU9v62vJzdI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Propuesta de soluci\u00f3n en <strong>Python<\/strong> 3ra Eva. II T\u00e9rmino 2015 Tema 1 y 2<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Algoritmo en Python<\/h2>\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_T2 Gestionar mensajes con etiquetas\n# propuesta: edelros@espol.edu.ec\n# version con lazos y condicionales.\n# tarea: simplificar con 'for'\n\nimport numpy as np\n\n# Tema 1. literal a)\ndef buscaetiqueta(mensaje):\n    n = len(mensaje)\n    etiquetas = &#x5B;]\n    copia = 0\n    \n    i = 0\n    while not(i&gt;=n):\n\n        #Inicia copia etiqueta\n        if (mensaje&#x5B;i]=='#'): \n            copia = 1\n            encontre = ''\n        \n        if (copia==1):\n            encontre = encontre + mensaje&#x5B;i]\n            if (i&lt;(n-1)):\n                if (mensaje&#x5B;i+1]==' ' or mensaje&#x5B;i+1]==','):\n                    copia = 0\n                    etiquetas.append(encontre)\n            if (i==(n-1)):\n                etiquetas.append(encontre)\n        i = i + 1\n    return(etiquetas)\n\n# Tema 1. literal b)\ndef tabulando(lista):\n    n = len(lista) # usando listas\n    repetido = np.zeros(n,dtype=int)\n    numrepetido = 0\n\n    # Marcando repetidos\n    i = 0 \n    while not(i&gt;=(n-1)):\n        j = i + 1\n        while not(j&gt;=n):\n            if (lista&#x5B;i]==lista&#x5B;j]):\n                repetido&#x5B;j]=1\n                numrepetido=numrepetido+1\n            j = j + 1\n        i = i + 1\n\n    #copia vector unicos, tabula usando arreglo\n    unicos = &#x5B;]\n    i = 0\n    while not(i&gt;=n):\n        if (repetido&#x5B;i]==0):\n            unicos.append(&#x5B;lista&#x5B;i],0])\n        i = i + 1\n    k = len(unicos)\n\n    # Cuenta y Acumula\n    i = 0\n    while not(i&gt;=n):\n        \n        #busca posicion en unicos\n        j = 0     \n        while not(j&gt;=k):\n            if (lista&#x5B;i]==unicos&#x5B;j]&#x5B;0]):\n                unicos&#x5B;j]&#x5B;1] = unicos&#x5B;j]&#x5B;1]+1\n            j = j + 1\n            \n        i = i + 1\n        \n    return(unicos)\n\n# Tema 2. Admnistra mensajes de una red social\nusuario = &#x5B;]\nmensaje = &#x5B;]\n\nopcion = 0\nwhile not(opcion==4):\n    print('1. Ingresar mensaje')\n    print('2. Usuario frecuente')\n    print('3. Tendencias')\n    print('4. Salir')\n\n    opcion = int(input('cual opcion: '))\n\n    if (opcion==1):\n        print('1. Ingresar mensaje')\n        quien = input('nombre usuario: ')\n        dice  = input('mensaje: ')\n        usuario.append(quien)\n        mensaje.append(dice)\n\n    if (opcion==2):\n        print('2. Usuario frecuente')\n        quienes = tabulando(usuario)\n        n = len(quienes)\n        mayor = 0\n        k = 1\n        while not (k&gt;=n):\n            if (quienes&#x5B;k]&#x5B;1]&gt;quienes&#x5B;mayor]&#x5B;1]):\n                mayor = k\n            k = k + 1\n        print('los usuarios:')\n        print(quienes)\n        print('el usuario mas frecuente es: ',\n                quienes&#x5B;mayor]&#x5B;0])\n\n    if (opcion==3):\n        print('3. Tendencias')\n        n = len(mensaje)\n        todaetiqueta = &#x5B;]\n        i = 0\n        while not(i&gt;=n):\n            cuales = buscaetiqueta(mensaje&#x5B;i])\n            m = len(cuales)\n            if (m&gt;0):\n                j = 0 #a\u00f1ade cada etiqueta\n                while not(j&gt;=m):\n                    todaetiqueta.append(cuales&#x5B;j])\n                    j = j+1\n            i = i + 1\n        etiquetas = tabulando(todaetiqueta)\n        n = len(etiquetas)\n        mayor = 0\n        k = 1\n        while not (k&gt;=n):\n            if (etiquetas&#x5B;k]&#x5B;1]&gt;etiquetas&#x5B;mayor]&#x5B;1]):\n                mayor = k\n            k = k + 1\n        print(etiquetas)\n        print('La tendencia es: ',etiquetas&#x5B;mayor]&#x5B;0])\n\n    if (opcion==4):\n        print('Gracias por usar el software')\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Ejercicio: 3Eva2015TII_T2 Gestionar mensajes con etiquetas Propuesta de soluci\u00f3n en Python 3ra Eva. II T\u00e9rmino 2015 Tema 1 y 2 Algoritmo en Python<\/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-1939","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\/1939","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=1939"}],"version-history":[{"count":4,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1939\/revisions"}],"predecessor-version":[{"id":23772,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1939\/revisions\/23772"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/media?parent=1939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/categories?post=1939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/tags?post=1939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}