{"id":1250,"date":"2014-03-14T08:55:53","date_gmt":"2014-03-14T13:55:53","guid":{"rendered":"http:\/\/blog.espol.edu.ec\/icm00794\/?p=1250"},"modified":"2026-04-05T17:13:20","modified_gmt":"2026-04-05T22:13:20","slug":"s1eva2008ti_t3-precio-petroleo","status":"publish","type":"post","link":"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-s1eva10\/s1eva2008ti_t3-precio-petroleo\/","title":{"rendered":"s1Eva2008TI_T3 Simular Precio del Petr\u00f3leo"},"content":{"rendered":"\n<p><em><strong>Ejercicio<\/strong><\/em>: <a href=\"https:\/\/blog.espol.edu.ec\/algoritmos101\/fp-1eva10\/1eva2008ti_t3-simular-precio-de-petroleo\/\" data-type=\"post\" data-id=\"3174\">1Eva2008TI_T3 Simular Precio del Petr\u00f3leo<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<div class=\"wp-block-group has-medium-font-size is-layout-flex wp-block-group-is-layout-flex\">\n<p><a href=\"\/algoritmos101\/#algoritmo\">algoritmo<\/a><\/p>\n\n\n\n<p>algoritmo <a href=\"\/algoritmos101\/#algoritmoarreglo\">con vector<\/a><\/p>\n\n\n\n<p><a href=\"\/algoritmos101\/#diagramaflujo\">diagrama flujo<\/a><\/p>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<figure class=\"wp-block-image alignright\"><img loading=\"lazy\" decoding=\"async\" width=\"422\" height=\"214\" src=\"http:\/\/blog.espol.edu.ec\/algoritmos101\/files\/2015\/03\/prpetroleo.gif\" alt=\"promedio valores grafico\" class=\"wp-image-214\" \/><\/figure>\n\n\n\n<p>Se ingresa la cantidad de d\u00edas del mes, <br>o se puede considerar directamente 30.<\/p>\n\n\n\n<p>Tambi\u00e9n es opcional ingresar el rango de precio m\u00ednimo y precio m\u00e1ximo, que son los l\u00edmites del n\u00famero aleatorio.<\/p>\n\n\n\n<p>Para la pregunta a) se calcula el promedio como el acumulado de precios de cada d\u00eda dividido para los <strong>n<\/strong> d\u00edas.<\/p>\n\n\n\n<p>En la pregunta b) se usa el algoritmo del menor, con la hip\u00f3tesis que el <strong><em>d\u00edamenor<\/em> <\/strong>es el primero, y que el precio menor es el m\u00e1ximo posible, a fin que se reemplace con el primer menor encontrado.<\/p>\n\n\n\n<p>Se deja la pregunta c) como tarea a fin de que se desarrolle el problema usando un arreglo.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<div class=\"wp-block-group has-medium-font-size is-layout-flex wp-block-group-is-layout-flex\">\n<p><a href=\"\/algoritmos101\/#algoritmo\">algoritmo<\/a><\/p>\n\n\n\n<p>algoritmo <a href=\"\/algoritmos101\/#algoritmoarreglo\">con vector<\/a><\/p>\n\n\n\n<p><a href=\"\/algoritmos101\/#diagramaflujo\">diagrama flujo<\/a><\/p>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\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_IT2008_T3 Simular Precio del Petr\u00f3leo\n# Propuesta: edelros@espol.edu.ec\n# Tarea: Realizar el literal c)\n\nimport random as rnd\n\n# INGRESO\nn = int(input('d\u00edas del mes: '))\n\n# PROCEDIMIENTO\nprcmax = 150\nprcmin = 130\nrango  = prcmax-prcmin+1\ndiamenor = 1\npmenor = prcmax\n\ndia = 1\ntotal = 0\nwhile (dia&lt;=n):\n    precio = int(rnd.random()*rango)+prcmin\n    total  = total+precio\n\n    if (precio&lt;pmenor):\n        diamenor = dia\n        pmenor   = precio\n\n    dia = dia+1\n\npromedio = total\/n\n\n# SALIDA\nprint('promedio: ')\nprint(promedio)\nprint('d\u00eda de menor precio:')\nprint(diamenor)\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<div class=\"wp-block-group has-medium-font-size is-layout-flex wp-block-group-is-layout-flex\">\n<p><a href=\"\/algoritmos101\/#algoritmo\">algoritmo<\/a><\/p>\n\n\n\n<p>algoritmo <a href=\"\/algoritmos101\/#algoritmoarreglo\">con vector<\/a><\/p>\n\n\n\n<p><a href=\"\/algoritmos101\/#diagramaflujo\">diagrama flujo<\/a><\/p>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Algoritmo en Python: usando arreglos<\/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_IT2008_T3 Simular Precio del Petr\u00f3leo\n# Tema 3. Precio petroleo-Arreglo\n# Propuesta: edelros@espol.edu.ec\n\nimport random as rnd\nimport numpy as np\n\n# INGRESO\nn = int(input('d\u00edas del mes: '))\n\n# PROCEDIMIENTO\nprcmax = 150\nprcmin = 130\nrango  = prcmax-prcmin+1\nprecio = np.zeros((n+1),dtype=int)\n\n# algoritmo del promedio\ntotal = 0\ndia   = 1\nwhile (dia&lt;=n):\n    precio&#x5B;dia] = int(rnd.random()*rango)+prcmin\n    total = total + precio&#x5B;dia]\n    dia   = dia + 1\n\npromedio = total\/n\n\n# algoritmo del menor\ndiamenor = 1\ndia = 1\nwhile (dia&lt;=n):\n    if precio&#x5B;dia]&lt;precio&#x5B;diamenor]:\n        diamenor = dia\n    dia = dia + 1\n\n# algoritmo precio superior al promedio\nsuperior = 0\ndia = 1\nwhile (dia&lt;=n):\n    if precio&#x5B;dia]&gt;promedio:\n        superior = superior + 1\n    dia = dia + 1\n\n# SALIDA\nprint('promedio: ')\nprint(promedio)\nprint('d\u00eda de menor precio:')\nprint(diamenor)\nprint('d\u00edas con precio sobre promedio:')\nprint(superior)\n<\/pre><\/div>\n\n\n<p>Resultado del algoritmo<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>d\u00edas del mes: 30\npromedio: \n140.06666666666666\nd\u00eda de menor precio:\n14\nd\u00edas con precio sobre promedio:\n16\n&gt;&gt;&gt; <\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<div class=\"wp-block-group has-medium-font-size is-layout-flex wp-block-group-is-layout-flex\">\n<p><a href=\"\/algoritmos101\/#algoritmo\">algoritmo<\/a><\/p>\n\n\n\n<p>algoritmo <a href=\"\/algoritmos101\/#algoritmoarreglo\">con vector<\/a><\/p>\n\n\n\n<p><a href=\"\/algoritmos101\/#diagramaflujo\">diagrama flujo<\/a><\/p>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Diagrama de Flujo<\/h3>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"426\" height=\"645\" src=\"http:\/\/blog.espol.edu.ec\/algoritmos101\/files\/2014\/03\/diagramaSimulaPrecioPetroleo01.png\" alt=\"diagrama Simula Precio Petroleo 01\" class=\"wp-image-19292\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"433\" height=\"442\" src=\"http:\/\/blog.espol.edu.ec\/algoritmos101\/files\/2014\/03\/diagramaSimulaPrecioPetroleo02.png\" alt=\"diagramaSimulaPrecioPetroleo02\" class=\"wp-image-19294\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"447\" height=\"460\" src=\"http:\/\/blog.espol.edu.ec\/algoritmos101\/files\/2014\/03\/diagramaSimulaPrecioPetroleo03.png\" alt=\"diagrama Simula Precio Petroleo 03\" class=\"wp-image-19295\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"164\" height=\"232\" src=\"http:\/\/blog.espol.edu.ec\/algoritmos101\/files\/2014\/03\/diagramaSimulaPrecioPetroleo04.png\" alt=\"diagrama Simula Precio Petroleo 04\" class=\"wp-image-19296\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<div class=\"wp-block-group has-medium-font-size is-layout-flex wp-block-group-is-layout-flex\">\n<p><a href=\"\/algoritmos101\/#algoritmo\">algoritmo<\/a><\/p>\n\n\n\n<p>algoritmo <a href=\"\/algoritmos101\/#algoritmoarreglo\">con vector<\/a><\/p>\n\n\n\n<p><a href=\"\/algoritmos101\/#diagramaflujo\">diagrama flujo<\/a><\/p>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n","protected":false},"excerpt":{"rendered":"<p>Ejercicio: 1Eva2008TI_T3 Simular Precio del Petr\u00f3leo algoritmo algoritmo con vector diagrama flujo Se ingresa la cantidad de d\u00edas del mes, o se puede considerar directamente 30. Tambi\u00e9n es opcional ingresar el rango de precio m\u00ednimo y precio m\u00e1ximo, que son los l\u00edmites del n\u00famero aleatorio. Para la pregunta a) se calcula el promedio como el [&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":[125],"tags":[58,157],"class_list":["post-1250","post","type-post","status-publish","format-standard","hentry","category-fp-s1eva10","tag-ejemplos-python","tag-fundamentos-programacion"],"_links":{"self":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1250","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=1250"}],"version-history":[{"count":5,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1250\/revisions"}],"predecessor-version":[{"id":23564,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/posts\/1250\/revisions\/23564"}],"wp:attachment":[{"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/media?parent=1250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/categories?post=1250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espol.edu.ec\/algoritmos101\/wp-json\/wp\/v2\/tags?post=1250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}