{"id":1645,"date":"2014-08-04T14:15:09","date_gmt":"2014-08-04T19:15:09","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/icm00794\/?p=1645"},"modified":"2026-04-05T18:28:46","modified_gmt":"2026-04-05T23:28:46","slug":"s3eva2003ti_t3-reportar-notas-desde-un-archivo","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-s3eva10\/s3eva2003ti_t3-reportar-notas-desde-un-archivo\/","title":{"rendered":"s3Eva2003TI_T3 Reportar notas desde un archivo"},"content":{"rendered":"\n<p><em><strong>Ejercicio<\/strong><\/em>: <a href=\"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-3eva10\/3eva2003ti_t3-reportar-notas-desde-un-archivo\/\" data-type=\"post\" data-id=\"2496\">3Eva2003TI_T3 Reportar notas desde un archivo<\/a><\/p>\n\n\n\n<p>Propuesta de soluci\u00f3n en <strong>Python<\/strong>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code alignwide\"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# ICM00794-Fundamentos de Computaci\u00f3n - FCNM-ESPOL\n# 3Eva_IT2003_T3 Reportar notas desde un archivo\n# Usando un menu para cada accion\n\nn = 0 # Sin notas\n\nopcion = '0'\nwhile not(opcion=='4'):\n    print('1. Ingresar notas y Guardar archivo')\n    print('2. Abrir archivo de notas')\n    print('3. Calcular promedio y Guardar archivo notasfinal')\n    print('4. Salir')\n    \n    opcion = input(' -- cual opcion: ')\n\n    if (opcion=='1'):\n        # Ingresar datos\n        nota = &#x5B;]\n        n = int(input('cuantos estudiantes: '))\n        for i in range(0,n,1):\n            matricula = input('matricula: ')\n            apellido = input('apellido: ')\n            nota1 = int(input('nota1 : '))\n            nota2 = int(input('nota2 : '))\n            nota.append(&#x5B;matricula,apellido,nota1,nota2])\n\n        # Crear archivo 'notas.txt' datos separados por ','\n        archivo = open('notas.txt','w')\n        for i in range(0,n,1):\n            linea = nota&#x5B;i]&#x5B;0]+','+nota&#x5B;i]&#x5B;1]+','\n            linea = linea +str(nota&#x5B;i]&#x5B;2])+','+str(nota&#x5B;i]&#x5B;3])+'\\n'\n            archivo.write(linea)\n            \n        print('archivo almacenado')\n        archivo.close()\n        \n    if (opcion=='2'):\n        # Abrir archivo de notas\n        nota = &#x5B;]\n        archivo = open('notas.txt','r')\n        linea = archivo.readline()\n        \n        #leer por linea hasta final ''\n        while not(linea==''): \n            # Separa y convierte tipo de datos\n            dato = linea.split(',')\n            matricula = dato&#x5B;0]\n            apellido  = dato&#x5B;1]\n            nota1 = int(dato&#x5B;2])\n            nota2 = int(dato&#x5B;3])\n            nota.append(&#x5B;matricula,apellido,nota1,nota2])\n\n            # Lee la siguiente linea\n            linea = archivo.readline()\n        archivo.close()\n        print('Datos leidos desde archivo')\n        print(nota)\n\n    if (opcion=='3'):\n        # Calcula promedio\n        n = len(nota)\n        promedio = &#x5B;]\n        for i in range(0,n,1):\n            prm = float((nota&#x5B;i]&#x5B;2]+nota&#x5B;i]&#x5B;3])\/2)\n            promedio.append(&#x5B;prm])\n        # Crear archivo 'final.txt' datos separados por ','\n        archivo = open('final.txt','w')\n        for i in range(0,n,1):\n            linea = nota&#x5B;i]&#x5B;0]+','+nota&#x5B;i]&#x5B;1]\n            linea = linea +','+str(promedio&#x5B;i])+'\\n'\n            archivo.write(linea)\n        print('archivo almacenado')\n        archivo.close()\n        \n    if (opcion=='4'):\n        print('Mejoramiento I T\u00e9rmino 2003, Tema 3')\n        print('icm00794 Fundamentos de computacion')\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Ejercicio: 3Eva2003TI_T3 Reportar notas desde un archivo Propuesta de soluci\u00f3n 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":[138],"tags":[58,157],"class_list":["post-1645","post","type-post","status-publish","format-standard","hentry","category-fp-s3eva10","tag-ejemplos-python","tag-fundamentos-programacion"],"_links":{"self":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1645","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=1645"}],"version-history":[{"count":4,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1645\/revisions"}],"predecessor-version":[{"id":23746,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1645\/revisions\/23746"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/media?parent=1645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/categories?post=1645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/tags?post=1645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}