{"id":8104,"date":"2014-02-11T08:25:04","date_gmt":"2014-02-11T13:25:04","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/ccpg1001\/?p=8104"},"modified":"2026-04-05T17:44:25","modified_gmt":"2026-04-05T22:44:25","slug":"s1eva2013tii_t2-numeros-palindromo-con-python","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-s1eva20\/s1eva2013tii_t2-numeros-palindromo-con-python\/","title":{"rendered":"s1Eva2013TII_T2 N\u00fameros pal\u00edndromo con Python"},"content":{"rendered":"\n<p><em><strong>Ejercicios<\/strong><\/em>: <a href=\"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-1eva20\/1eva2013tii_t2-numeros-palindromo-con-python\/\" data-type=\"post\" data-id=\"3263\">1Eva2013TII_T2 N\u00fameros pal\u00edndromo con Python<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image alignright size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"554\" height=\"335\" src=\"http:\/\/blog.espol.edu.ec\/algoritmos101\/files\/2014\/03\/simetricoAsimetrico01.png\" alt=\"sim\u00e9trico Asimetrico\" class=\"wp-image-16599\" \/><\/figure>\n\n\n\n<p><strong>Literal a<\/strong>. Para invertir los d\u00edgitos de un n\u00famero, se usan residuo y el cociente para extraer cada d\u00edgito y rearmarlo en otro n\u00famero con posiciones invertidas. <\/p>\n\n\n\n<p>Se compara el n\u00famero de forma inversa para verificar si el igual al n\u00famero original, siendo solamente as\u00ed un n\u00famero pal\u00edndromo.<\/p>\n\n\n\n<p><strong>Tarea<\/strong>: implementar el literal b a partir de la soluci\u00f3n del literal a.<\/p>\n\n\n\n<p>Para iniciar la b\u00fasqueda de los n\u00fameros pal\u00edndromos se inicia con dos d\u00edgitos es decir numero=10. Se aplica el algoritmo al n\u00famero y se repite el proceso con un lazo hasta llegar al mill\u00f3n-1<\/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# 1Eva_IIT2013_T2 N\u00fameros pal\u00edndromo\n\n# INGRESO\nnumero = int(input('numero a revisar: '))\n\n# PROCEDIMIENTO\nnumcopia = numero\ncociente = numero\n\n# invierte d\u00edgitos del n\u00famero\ninvertido = 0\nwhile not(cociente&lt;=0):\n    numcopia = cociente\n    cociente = numcopia\/\/10\n    residuo  = numcopia%10\n    invertido = invertido*10 + residuo\n\n# revisa si el n\u00famero es igual a invertido\nif (invertido == numero):\n    palindromo = 1\nelse:\n    palindromo = 0\n\n# SALIDA\nprint('numero invertido: ', invertido)\nprint('Palindromo:', palindromo)\n<\/pre><\/div>\n\n\n<p>Ejecuci\u00f3n del algoritmo<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>numero a revisar: 1991\nnumero invertido:  1991\nPalindromo: 1\n&gt;&gt;&gt; \nnumero a revisar: 2112\nnumero invertido:  2112\nPalindromo: 1\n&gt;&gt;&gt; \nnumero a revisar: 2020\nnumero invertido:  202\nPalindromo: 0\n&gt;&gt;&gt; <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ejercicios: 1Eva2013TII_T2 N\u00fameros pal\u00edndromo con Python Literal a. Para invertir los d\u00edgitos de un n\u00famero, se usan residuo y el cociente para extraer cada d\u00edgito y rearmarlo en otro n\u00famero con posiciones invertidas. Se compara el n\u00famero de forma inversa para verificar si el igual al n\u00famero original, siendo solamente as\u00ed un n\u00famero pal\u00edndromo. Tarea: [&hellip;]<\/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":[130],"tags":[58,157],"class_list":["post-8104","post","type-post","status-publish","format-standard","hentry","category-fp-s1eva20","tag-ejemplos-python","tag-fundamentos-programacion"],"_links":{"self":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/8104","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=8104"}],"version-history":[{"count":4,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/8104\/revisions"}],"predecessor-version":[{"id":23632,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/8104\/revisions\/23632"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/media?parent=8104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/categories?post=8104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/tags?post=8104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}