{"id":7625,"date":"2019-02-16T06:51:54","date_gmt":"2019-02-16T11:51:54","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/ccpg1001\/?p=7625"},"modified":"2026-04-05T18:32:38","modified_gmt":"2026-04-05T23:32:38","slug":"s3eva2018tii_t1-texto-aleatorio","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-s3eva20\/s3eva2018tii_t1-texto-aleatorio\/","title":{"rendered":"s3Eva2018TII_T1 texto aleatorio"},"content":{"rendered":"\n<p><em><strong>Ejercicio<\/strong><\/em>: <a href=\"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-3eva20\/3eva2018tii_t1-texto-aleatorio\/\" data-type=\"post\" data-id=\"7617\">3Eva2018TII_T1 texto aleatorio<\/a><\/p>\n\n\n\n<p>Propuesta de soluci\u00f3n en <strong>Python<\/strong>:<br>Ejemplo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>El texto generado es: \nHola Hola.\nHola amigo-amiga Hola que-\n&gt;&gt;&gt; <\/code><\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# CCPG1001-Fundamentos de Programaci\u00f3n - FIEC-ESPOL\n# 3Eva_IIT2018_T1 texto aleatorio\n\nimport random as rnd\n\n# INGRESO\nn = 10 # enunciado con 73\nT = &#x5B;'Hola','.','que','tal','-',',','amigo','amiga']\n\n# PROCEDIMIENTO\nk = len(T)\ntexto   = ''\nsimbolo = ',.-'\nantes   = 0\ncuenta  = 0\nwhile not(cuenta&gt;=n):\n    aleatorio = int(rnd.random()*k)+0\n    untermino =  T&#x5B;aleatorio]\n    espalabra = not(untermino in simbolo)\n    if cuenta == 0 and espalabra==1:\n        texto  = texto + untermino\n        cuenta = cuenta + 1\n        antes  = espalabra\n    if cuenta &gt;0:\n        if espalabra == 1:\n            if antes == 1:\n                texto = texto + ' '+ untermino\n            if antes == 0:\n                texto = texto + untermino\n            antes  = 1\n            cuenta = cuenta+1\n        if espalabra==0 and antes==1:\n            if untermino==',':\n                texto = texto + ', '\n            if untermino=='.':\n                texto = texto + '.\\n'\n            if untermino=='-':\n                texto = texto +'-'\n            antes = 0\n            cuenta = cuenta+1\n        # if espalabra==0 and antes ==0:\n        #     print('no se pueden juntar simbolos')\n\n# SALIDA\nprint('El texto generado es: ')\nprint(texto)\n\n# Archivo\narchivo = open('literatura.txt','w')\narchivo.write(texto)\narchivo.close()\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Ejercicio: 3Eva2018TII_T1 texto aleatorio Propuesta de soluci\u00f3n en Python:Ejemplo:<\/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-7625","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\/7625","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=7625"}],"version-history":[{"count":4,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/7625\/revisions"}],"predecessor-version":[{"id":23755,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/7625\/revisions\/23755"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/media?parent=7625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/categories?post=7625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/tags?post=7625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}