<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6557679628416245687</id><updated>2026-10-10T15:05:25.876-07:00</updated><category term="Cursos de programación Python"/><category term="Cursos de programación"/><category term="Pensar como programador"/><category term="Tecnicas para programar mejor"/><category term="técnica para programar mejor"/><category term="ser mejor programador"/><category term="Pyhon"/><category term="python"/><category term="Lista"/><category term="for"/><category term="bucles"/><category term="Las listas son mutables"/><category term="cadenas"/><category term="7.6. Las cadenas son inmutables"/><category term="7.9. El módulo “string”"/><category term="Alias (poner sobrenombres)"/><category term="Listas como parámetros"/><category term="Valores de una lista"/><category term="encapsulación"/><category term="Clasificación de caracteres"/><category term="Pertenencia a una lista"/><category term="Tuplas"/><category term="clonar listas"/><category term="indice"/><category term="longitud de una lista"/><category term="programación"/><category term="slices"/><category term="Acceso a los elementos"/><category term="Comparación de cadenas"/><category term="Encapsulado"/><category term="Porciones"/><category term="Un tipo de datos compuesto"/><category term="pen"/><category term="programacion"/><category term="py"/><category term="1.1. El lenguaje de programación Python"/><category term="1.2. ¿Qué es un programa?"/><category term="1.3.1. Errores sintácticos"/><category term="1.3.2. Errores en tiempo de ejecución"/><category term="1.3.3. Errores semánticos"/><category term="1.3.4. Depuración experimental"/><category term="1.4. Lenguajes formales y lenguajes naturales"/><category term="1.5. El primer programa"/><category term="1.6 glosario"/><category term="5.8. Comprobación de tipos"/><category term="6.1. Asignación múltiple"/><category term="6.2. La sentencia while"/><category term="Depuración experimental"/><category term="El lenguaje de programación Python"/><category term="Errores en tiempo de ejecución"/><category term="Errores semánticos"/><category term="Errores sintácticos"/><category term="Longitud"/><category term="Objetos y valores"/><category term="Operaciones con listas"/><category term="Porciones (slices)"/><category term="Porciones de cadenas"/><category term="Tablas"/><category term="Tablas de dos dimensiones"/><category term="capitulo 1"/><category term="el camino del programa"/><category term="matrices"/><category term="pens"/><category term="pensa"/><category term="programador"/><category term="pyt"/><category term="pyth"/><category term="sistemas"/><category term="unidad 5"/><category term="¿Qué es un programa?"/><title type='text'>Aprenda a pensar como programador</title><subtitle type='html'>Programando en python</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>263</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-4429797291226276651</id><published>2014-02-19T22:36:00.000-08:00</published><updated>2014-02-19T22:36:00.527-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="capitulo 1"/><category scheme="http://www.blogger.com/atom/ns#" term="el camino del programa"/><category scheme="http://www.blogger.com/atom/ns#" term="programación"/><category scheme="http://www.blogger.com/atom/ns#" term="py"/><category scheme="http://www.blogger.com/atom/ns#" term="Pyhon"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Capítulo 1</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h1&gt;El Camino del Programa&lt;/h1&gt; &lt;p align=&quot;justify&quot;&gt;&lt;br&gt;El objetivo de este libro es enseñarle a pensar como lo hacen los científicos informáticos. Esta manera de pensar combina las mejores características de la matemática, la ingeniería, y las ciencias naturales. Como los matemáticos, los científicos informáticos usan lenguajes formales para designar ideas (específicamente, computaciones). Como los ingenieros, ellos diseñan cosas, ensamblando sistemas a partir de componentes y evaluando ventajas y desventajas de cada una de las alternativas. Como los científicos, ellos observan el comportamiento de sistemas complejos, forman hipótesis, y prueban sus predicciones. &lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;La habilidad más importante del científico informático es la soluciún de problemas. La soluciún de problemas incluye poder formular problemas, pensar en la solución de manera creativa, y expresar una solución con claridad y precisión.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Como se verá, el proceso de aprender a programar es la oportunidad perfecta para desarrollar la habilidad de resolver problemas. Por esa razón este capítulo se llama &quot;El Camino del programa&quot;.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;A cierto nivel, usted aprenderá a programar, lo cual es una habilidad muy útil por sí misma. A otro nivel, usted utilizará la programaciún para obtener algún resultado. Ese resultado se verá más claramente durante el proceso.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/4429797291226276651/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/capitulo-1.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4429797291226276651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4429797291226276651'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/capitulo-1.html' title='Capítulo 1'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-1331982383060903947</id><published>2014-02-19T22:29:00.000-08:00</published><updated>2014-02-19T22:29:00.102-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.1. El lenguaje de programación Python"/><category scheme="http://www.blogger.com/atom/ns#" term="El lenguaje de programación Python"/><title type='text'>1.1. El lenguaje de programación Python</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;El lenguaje de programación que aprenderá es Python. Python es un ejemplar de un&lt;strong&gt; lenguaje de alto nivel&lt;/strong&gt;; otros ejemplos de lenguajes de alto nivel son C, C++, Perl y Java.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Como se puede deducir de la nomenclatura &lt;strong&gt;“lenguaje de alto nivel&quot;&lt;/strong&gt;, también existen lenguajes de bajo nivel, a los que también se califica como lenguajes de máquina o lenguajes ensambladores. A propósito, los computadores sólo ejecutan programas escritos en lenguajes de bajo nivel. Los programas de alto nivel tienen que traducirse antes de ejecutarse. Esta traducción lleva tiempo, lo cual es una pequeña desventaja de los lenguajes de alto nivel.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Aun así las ventajas son enormes. En primer lugar, la programación en lenguajes de alto nivel es mucho más fácil; escribir programas en un lenguaje de alto nivel toma menos tiempo, los programas son más cortos y más fáciles de leer, y es más probable que estos programas sean correctos. En segundo lugar, los lenguajes de alto nivel son &lt;strong&gt;portables&lt;/strong&gt;, lo que significa que pueden ejecutarse en tipos diferentes de computadores sin modificación alguna o con pocas modificaciones. &lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Los programas escritos en lenguajes de bajo nivel sólo pueden ser ejecutarse en un tipo de computador y deben reescribirse para ejecutarlos en otro.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Debido a estas ventajas, casi todos los programa se escriben en un lenguaje de alto nivel. Los lenguajes de bajo nivel sólo se usan para unas pocas aplicaciones&lt;br&gt;especiales.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Hay dos tipos de programas que traducen&lt;strong&gt; lenguajes de alto nivel a lenguajes&lt;/strong&gt; de bajo nivel: &lt;strong&gt;intérpretes y compiladores&lt;/strong&gt;. Un intérprete lee un programa de alto nivel y lo ejecuta, lo que significa que lleva a cabo lo que indica el programa.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Traduce el programa poco a poco, leyendo y ejecutando cada comando.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbnlU1kfRGFxQlPjfomdzBkHCycyzqxoXaQAW7l5jCJOC5-B5qbBfoYEMUM3T4J2-fF1baO9oNVLM2rPEPMIfDcTKY5fQCq2dtTBVcXvUbngDrtO6Aq3KgGr0YAJPIoRUnmVyXSjm9YjGF/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg01puZJPjiKLF1JYupNt37HZk_tLpqRh-DFcRw8aH9fKoxe7EOQp3xtjgd3IOqd4aysphfViUDEPsItskDCH_qu-I_W3ic-ljFQhpWxG58T_PWKGi5w0qBUmjl-XoO5oKH8Ynyt9d61w88/?imgmax=800&quot; width=&quot;248&quot; height=&quot;65&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Un compilador lee el programa y lo traduce todo al mismo tiempo, antes de ejecutar cualquiera de las instrucciones. En este caso, al programa de alto nivel se le llama el &lt;strong&gt;código fuente&lt;/strong&gt;, y al programa traducido el &lt;strong&gt;código de objeto&lt;/strong&gt; o el &lt;strong&gt;código ejecutable&lt;/strong&gt;. Una vez compilado el programa, puede ejecutarlo&lt;br&gt;repetidamente sin volver a traducirlo.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi36ivsBbNhxD6yXckDoAMyXbmlkEhxCNtZJpd3SUXsPZ1nm4TU7cPPMTk-mY_EgkmJYRHDyVX9VSyGakhzI007v6OaWMJvB-bEZ29eTnRe2UH77TDUQPwjxOGuVtlL974sAgoBjmUHpMgg/s1600-h/image%25255B7%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqklHwQ-8VN_FE6Gzvlyl3vutQJBbpKIO8PwDAoyH6-ZBASAVqXtJjOv8lZ5jKwKTs6nctO4rF6h_LL7JZnqYVIY0jAbKpHfwY_Lz8NDhSDKjFlWcp8hI2p4XHaoFYPYHlUR_sFY0uH5GL/?imgmax=800&quot; width=&quot;386&quot; height=&quot;68&quot;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Python se considera como lenguaje interpretado porque los programas de Python se ejecutan por medio de un intérprete. Existen dos maneras de usar el&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;intérprete: modo de comando y modo de guión. En modo de comando se escriben sentencias en el lenguaje Python y el intérprete muestra el resultado.&lt;br&gt;&lt;br&gt; &lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt; &lt;div id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: white&quot;&gt;&lt;span id=&quot;lnum1&quot; style=&quot;color: #606060&quot;&gt;   1:&lt;/span&gt; $ python&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span id=&quot;lnum2&quot; style=&quot;color: #606060&quot;&gt;   2:&lt;/span&gt; Python 1.5.2 (#1, Feb 1 2000, 16:32:16)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: white&quot;&gt;&lt;span id=&quot;lnum3&quot; style=&quot;color: #606060&quot;&gt;   3:&lt;/span&gt; Copyright 1991-1995 Stichting Mathematish Centrum, Amsterdam&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span id=&quot;lnum4&quot; style=&quot;color: #606060&quot;&gt;   4:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; print 1 + 1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: white&quot;&gt;&lt;span id=&quot;lnum5&quot; style=&quot;color: #606060&quot;&gt;   5:&lt;/span&gt; 2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;La primera línea de este ejemplo es el comando que pone en marcha el intérprete&lt;br&gt;Python. Las dos líneas siguientes son mensajes del intérprete. La tercera línea comienza con &amp;gt;&amp;gt;&amp;gt;, que es la invitación del intérprete para indicar que está listo.&lt;br&gt;Escribimos print 1 + 1 y el intérprete contestó 2.Alternativamente, se puede escribir el programa en un archivo y usar el intérprete para ejecutar el contenido de dicho archivo. El archivo se llama, en este caso, un guión. Por ejemplo, en un editor de texto se puede crear un archivo latoya.py que contenga esta línea:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: white&quot;&gt;&lt;span id=&quot;lnum1&quot; style=&quot;color: #606060&quot;&gt;   1:&lt;/span&gt; print 1 + 1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Por acuerdo unánime, los archivos que contienen programas de Python tienen nombres que terminan con .py.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Para ejecutar el programa, se le tiene que indicar el nombre del guión al intérprete.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt;&lt;br /&gt;&lt;div id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: white&quot;&gt;&lt;span id=&quot;lnum1&quot; style=&quot;color: #606060&quot;&gt;   1:&lt;/span&gt; $ python latoya.py&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;span id=&quot;lnum2&quot; style=&quot;color: #606060&quot;&gt;   2:&lt;/span&gt; 2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;En otros entornos de desarrollo los detalles de la ejecución de programas pueden ser diferentes. Además, la mayoría de programas son más interesantes que el mencionado.&lt;br&gt;La mayoría de ejemplos en este libro se ejecutan desde en la línea de comando.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;La línea de comando es muy apropiada para el desarrollo de programas y para pruebas rápidas porque se pueden teclear las instrucciones de Python y se pueden ejecutar inmediatamente. Una vez que un programa está completo, puede archivarse en un guión para ejecutarlo o modificarlo en el futuro.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/1331982383060903947/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/11-el-lenguaje-de-programacion-python.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/1331982383060903947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/1331982383060903947'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/11-el-lenguaje-de-programacion-python.html' title='1.1. El lenguaje de programación Python'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg01puZJPjiKLF1JYupNt37HZk_tLpqRh-DFcRw8aH9fKoxe7EOQp3xtjgd3IOqd4aysphfViUDEPsItskDCH_qu-I_W3ic-ljFQhpWxG58T_PWKGi5w0qBUmjl-XoO5oKH8Ynyt9d61w88/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-2645046761521609565</id><published>2014-02-19T22:15:00.000-08:00</published><updated>2014-02-19T22:15:00.596-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.2. ¿Qué es un programa?"/><category scheme="http://www.blogger.com/atom/ns#" term="programacion"/><category scheme="http://www.blogger.com/atom/ns#" term="pyt"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="¿Qué es un programa?"/><title type='text'>1.2. ¿Qué es un programa?</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Un &lt;strong&gt;programa&lt;/strong&gt; es una secuencia de instrucciones que especifican cómo ejecutar una computación. La computación puede ser algo matemático, como solucionar un sistema de ecuaciones o determinar las raíces de un polinomio, pero también puede ser una computación simbólica, como buscar y reemplazar el texto de un documento o (aunque parezca raro) compilar un programa.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Las instrucciones (comandos, órdenes) tienen una apariencia diferente en lenguajes de programación diferentes, pero existen algunas funciones básicas que&lt;br&gt;se presentan en casi todo lenguaje:&lt;/p&gt; &lt;blockquote&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;entrada:&lt;/strong&gt; Recibir datos del teclado, o un archivo u otro aparato.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;salida:&lt;/strong&gt; Mostrar datos en el monitor o enviar datos a un archivo u otro aparato.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;matemáticas:&lt;/strong&gt; Ejecutar operaciones básicas de matemáticas como la adición y la multiplicación.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;operación condicional:&lt;/strong&gt; Probar la veracidad de alguna condición y ejecutar una secuencia de instrucciones apropiada.&lt;br&gt;repetición: Ejecutar alguna acción repetidas veces, normalmente con alguna variación.&lt;/p&gt;&lt;/blockquote&gt; &lt;p align=&quot;justify&quot;&gt;Lo crea o no, eso es todo. Todos los programas que existen, por complicados que sean, están formulados exclusivamente con tales instrucciones. Así, una manera de describir la programación es: El proceso de romper una tarea en tareas cada vez más pequeñas hasta que estas tareas sean suficientemente simples para ser ejecutadas con una de estas instrucciones simples.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Quizás esta descripción sea un poco ambigua. No se preocupe. Lo explicaremos con más detalle con el tema de los &lt;strong&gt;algoritmos&lt;/strong&gt;.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/2645046761521609565/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/12-que-es-un-programa.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2645046761521609565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2645046761521609565'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/12-que-es-un-programa.html' title='1.2. ¿Qué es un programa?'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-7181332495036786200</id><published>2014-02-19T22:08:00.000-08:00</published><updated>2014-02-19T22:08:00.038-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.3.1. Errores sintácticos"/><category scheme="http://www.blogger.com/atom/ns#" term="Errores sintácticos"/><category scheme="http://www.blogger.com/atom/ns#" term="pensa"/><category scheme="http://www.blogger.com/atom/ns#" term="Pensar como programador"/><category scheme="http://www.blogger.com/atom/ns#" term="py"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>1.3.1. Errores sintácticos</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Python solo puede ejecutar un programa si el programa es correcto sintácticamente. En caso contrario, es decir si el programa no es correcto sintácticamente, el proceso falla y devuelve un mensaje de error. El término sintaxis se refiere a la estructura de cualquier programa y a las reglas de esa estructura. Por ejemplo, en español la primera letra de toda oración debe ser mayúscula, y todas las oraciones deben terminar con un punto. esta oración tiene un error sintáctico.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Esta oración también para la mayoría de lectores, unos pocos errores sintácticos no son significativos, y por eso pueden leer la poesía de e. e. cummings sin anunciar errores de sintaxis. Python no es tan permisivo. Si hay aunque sea un solo error sintáctico en el programa, Python mostrará un mensaje de error y abortará la ejecución del programa. Durante las primeras semanas de su carrera como programador pasará, seguramente, mucho tiempo buscando errores sintácticos. Sin embargo, tal como adquiera experiencia tendrá menos errores y los encontrará mas rápido.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/7181332495036786200/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/131-errores-sintacticos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7181332495036786200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7181332495036786200'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/131-errores-sintacticos.html' title='1.3.1. Errores sintácticos'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-2395884699276346420</id><published>2014-02-19T21:59:00.000-08:00</published><updated>2014-02-19T21:59:00.036-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.3.3. Errores semánticos"/><category scheme="http://www.blogger.com/atom/ns#" term="Errores semánticos"/><category scheme="http://www.blogger.com/atom/ns#" term="pen"/><category scheme="http://www.blogger.com/atom/ns#" term="Pensar como programador"/><category scheme="http://www.blogger.com/atom/ns#" term="programación"/><title type='text'>1.3.3. Errores semánticos</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;El tercer tipo de error es el error semántico. Si hay un error de lógica en su programa, el programa se ejecutará sin ningún mensaje de error, pero el resultado no será el deseado. Será cualquier otra cosa. Concretamente, el programa hará lo que usted le dijo.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;A veces ocurre que el programa escrito no es el programa que se tenía en mente.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;El sentido o significado del programa (su semántica) no es correcto. Es difícil hallar errores de lógica, porque requiere trabajar al revés, observando el resultado del programa para averiguar lo que hace.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/2395884699276346420/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/133-errores-semanticos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2395884699276346420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2395884699276346420'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/133-errores-semanticos.html' title='1.3.3. Errores semánticos'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-8575834587356844287</id><published>2014-02-19T21:53:00.000-08:00</published><updated>2014-02-19T21:53:00.605-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.3.4. Depuración experimental"/><category scheme="http://www.blogger.com/atom/ns#" term="Depuración experimental"/><category scheme="http://www.blogger.com/atom/ns#" term="pens"/><category scheme="http://www.blogger.com/atom/ns#" term="Pensar como programador"/><title type='text'>1.3.4. Depuración experimental</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Una de las técnicas mas importantes que usted aprendería es la depuración. Aunque a veces es frustrante, la depuración es una de las partes mías intelectualmentericas, interesantes y estimulantes de la programación.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;La depuración es una actividad parecida a la tarea de un investigador: se tienen que estudiar las claves para inducir los procesos y eventos llevaron a los&lt;br&gt;resultados que tiene a la vista.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;La depuración también es una ciencia experimental. Una vez que se tiene la idea de cual es el error, se modifica el programa y se intenta nuevamente. Si su hipótesis fue la correcta se pueden predecir los resultados de la modificación y estaría mías cerca de un programa correcto. Si su hipótesis fue errónea tendría que idearse otra hipótesis. Como dijo Sherlock Holmes, &quot;Cuando se ha descartado lo imposible, lo que queda, no importa cuan inverosímil, debe ser la verdad.&quot;(A. Conan Doyle, The Sign of Four)&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Para algunas personas, la programación y la depuración son lo mismo: la programación es el proceso de depurar un programa gradualmente hasta que haga lo que usted quiera. La idea es que deberí³a usted comenzar con un programa que haga algo y hacer pequeñas modificaciones, depurándolas sobre la marcha, de modo que siempre tenga un programa que funcione.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Por ejemplo, Linux es un sistema operativo que contiene miles de lí³neas de código, pero Linus Torvalds lo comenzó como un programa para explorar el microprocesador Intel 80836. Según Larry Greenfield, &quot;Uno de los proyectos tempranos de Linus fue un programa que alternaba la impresión de AAAA con BBBB. Este programa evolucionó en Linux&quot; (de The Linux Users&#39;Guide Versión Beta 1).&lt;br&gt;Otros capítulos tratarían mas acerca del tema de depuración y otras técnicas de programación.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/8575834587356844287/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/134-depuracion-experimental.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/8575834587356844287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/8575834587356844287'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/134-depuracion-experimental.html' title='1.3.4. Depuración experimental'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-6791656603097416872</id><published>2014-02-18T22:02:00.000-08:00</published><updated>2014-02-18T22:02:00.073-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.3.2. Errores en tiempo de ejecución"/><category scheme="http://www.blogger.com/atom/ns#" term="Errores en tiempo de ejecución"/><category scheme="http://www.blogger.com/atom/ns#" term="Pensar como programador"/><category scheme="http://www.blogger.com/atom/ns#" term="programación"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>1.3.2. Errores en tiempo de ejecución</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;El segundo tipo de error es un error en tiempo de ejecución. Este error no aparece hasta que se ejecuta el programa. Estos errores también se llaman excepciones&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;porque indican que algo excepcional (y malo) ha ocurrido.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Con los programas que vamos a escribir al principio, los errores en tiempo de ejecución ocurrirán con poca frecuencia, así que puede pasar bastante tiempo hasta que vea uno.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/6791656603097416872/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/132-errores-en-tiempo-de-ejecucion.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6791656603097416872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6791656603097416872'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/132-errores-en-tiempo-de-ejecucion.html' title='1.3.2. Errores en tiempo de ejecución'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-161908200781540971</id><published>2014-02-18T21:48:00.000-08:00</published><updated>2014-02-18T21:48:00.525-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.4. Lenguajes formales y lenguajes naturales"/><category scheme="http://www.blogger.com/atom/ns#" term="Pensar como programador"/><category scheme="http://www.blogger.com/atom/ns#" term="programador"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>1.4. Lenguajes formales y lenguajes naturales</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Los lenguajes naturales son los lenguajes hablados por seres humanos, como el español, el inglés y el francés. No los han diseñados personas (aunque se&lt;br&gt;intente poner cierto orden en ellos), sino que se han desarrollado naturalmente.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Los lenguajes formales son lenguajes diseñados por humanos y que tienen aplicaciones específicas. La notación matemática, por ejemplo, es un lenguaje formal ya que se presta a la representación de las relaciones entre números y símbolos. Los químicos utilizan un lenguaje formal para representar la estructura química de las moléculas. Y lo más importante:&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Los lenguajes de programación son lenguajes formales desarrollados para expresar computaciones.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Los lenguajes formales casi siempre tienen reglas sintácticas estrictas. Por ejemplo, &lt;strong&gt;3+3 = 6&lt;/strong&gt; es una expresión matemática correcta, pero &lt;strong&gt;3 = +6$&lt;/strong&gt; no lo es. De&lt;br&gt;la misma manera, H20 es una nomenclatura química correcta, pero &lt;strong&gt;2Zz&lt;/strong&gt; no lo es.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Existen dos clases de reglas sintácticas, en cuanto a unidades y estructura. Las unidades son los elementos básicos de un lenguaje, como lo son las palabras, los números y los elementos químicos. Por ejemplo, en&lt;strong&gt; 3=+6$, $&lt;/strong&gt; no es una unidad matemática aceptada (al menos hasta donde nosotros sabemos. Similarmente, &lt;strong&gt;2Zz&lt;/strong&gt; no es formal porque no hay ningún elemento con la abreviatura &lt;strong&gt;Zz&lt;/strong&gt;.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;La segunda clase de regla sintáctica está relacionada con la estructura de un elemento; o sea, el orden de las unidades. La estructura de la sentencia 3=+6$&lt;br&gt;no se acepta porque no se puede escribir el símbolo de igualdad seguido de un símbolo positivo. Similarmente, las fórmulas moleculares tienen que mostrar el número de subíndice después del elemento, no antes.&lt;br&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;p align=&quot;justify&quot;&gt;&lt;em&gt;A manera de práctica, trate de producir una oración con estructura aceptada pero que esté compuesta de unidades irreconocibles. Luego escriba otra oración con unidades aceptables pero con estructura no válida.&lt;br&gt;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p align=&quot;justify&quot;&gt;Al leer una oración, sea en un lenguaje natural o una sentencia en un lenguaje técnico, se debe discernir la estructura de la oración. En un lenguaje natural este proceso, llamado análisis sintáctico ocurre subconscientemente.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Por ejemplo cuando usted escucha la oración &quot;El otro zapato cayó&quot;, entiende que &quot;el otro zapato&quot; es el sujeto y &quot;cayó&quot; es el verbo. Cuando se ha analizado la oración sintácticamente, se puede deducir el significado, o la semántica, de la oración. Suponiendo que sepa lo que es un zapato y lo que es caer, entenderá el significado de la oración.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Aunque existen muchas cosas en común entre los lenguajes naturales y los lenguajes formales|por ejemplo las unidades, la estructura, la sintaxis y la&lt;br&gt;semántica|también existen muchas diferencias:&lt;br&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;ambigüedad:&lt;/strong&gt; Los lenguajes naturales tienen muchísimas ambigüedades, que los hablantes sortean usando claves contextuales y otra información. Los lenguajes formales se diseñan para estar completamente libres de am-&lt;/p&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;redundancia:&lt;/strong&gt; Para reducir la ambigüedad y los malentendidos, las lenguas naturales utilizan bastante redundancia. Como resultado suelen ser prolijos. Los lenguajes formales son menos redundantes y más concisos.&lt;br&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;literalidad:&lt;/strong&gt; Los lenguajes naturales tienen muchas metáforas y frases hechas.&lt;br&gt;&lt;strong&gt;programas:&lt;/strong&gt; El significado de un dicho, por ejemplo &quot;Estirar la pata&quot;, es diferente al significado de sus sustantivos y verbos. En este ejemplo, la oración no tiene nada que ver con un pie y significa &#39;morirse&#39;. Los lenguajes formales no difieren de su significado literal.&lt;br&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p align=&quot;justify&quot;&gt;Los que aprenden a hablar un lenguaje natural|es decir, todo el mundo| muchas veces tienen dificultad en adaptarse a los lenguajes formales. A veces&lt;br&gt;a diferencia entre los lenguajes formales y los naturales es comparable a la diferencia entre la prosa y la poesía:&lt;br&gt;&lt;/p&gt; &lt;blockquote&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;Poesía:&lt;/strong&gt; Se utiliza una palabra por su cualidad auditiva tanto como por su significado. El poema, en su totalidad, produce un efecto o reacción emocional.&lt;br&gt;La ambigüedad no es solo común sino utilizada a propósito.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;Prosa:&lt;/strong&gt; El significado literal de la palabra es mas importante y la estructura da más significado aún. La prosa se presta al análisis más que la poesía, pero todavía contiene ambigüedad.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;Programas:&lt;/strong&gt; El significado de un programa es inequívoco y literal, y es entendido en su totalidad analizando las unidades y la estructura.&lt;br&gt;He aquí unas sugerencias para la lectura de un programa (y de otros lenguajes formales). Primero, recuerde que los lenguajes formales son mucho más densos que los lenguajes naturales, y por consecuente lleva más tiempo leerlos. También, la estructura es muy importante, así que entonces no es una buena idea leerlo de pies a cabeza, de izquierda a derecha. En vez de eso, aprenda a separar las diferentes partes en su mente, identificar las unidades e interpretar la estructura. Finalmente, ponga atención a los detalles. Los fallos de puntuación y la ortografía, que puede obviar en el lenguaje natural, pueden suponer una gran diferencia en un lenguaje formal.&lt;/p&gt;&lt;/blockquote&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/161908200781540971/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/14-lenguajes-formales-y-lenguajes.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/161908200781540971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/161908200781540971'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/14-lenguajes-formales-y-lenguajes.html' title='1.4. Lenguajes formales y lenguajes naturales'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-3208939793612871566</id><published>2014-02-17T21:25:00.000-08:00</published><updated>2014-02-17T21:25:00.272-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.5. El primer programa"/><category scheme="http://www.blogger.com/atom/ns#" term="Pensar como programador"/><category scheme="http://www.blogger.com/atom/ns#" term="programacion"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="sistemas"/><title type='text'>1.5. El primer programa</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Tradicionalmente el primer programa en un lenguaje nuevo se llama &quot;Hola, mundo&quot; (Hello world!) porque sólo muestra las palabras &quot;Hola a todo el mundo&quot;.&lt;br&gt;&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;En Python es así:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;justify&quot;&gt; &lt;div id=&quot;codeSnippetWrapper&quot; style=&quot;overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; border-right: silver 1px solid; width: 97.5%; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 200px; background-color: #f4f4f4&quot;&gt; &lt;div id=&quot;codeSnippet&quot; style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4&quot;&gt;&lt;pre style=&quot;border-top-style: none; overflow: visible; font-size: 8pt; font-family: &#39;Courier New&#39;, courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: white&quot;&gt;&lt;span id=&quot;lnum1&quot; style=&quot;color: #606060&quot;&gt;   1:&lt;/span&gt; print &lt;span style=&quot;color: #006080&quot;&gt;&quot;Hola, mundo&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Este es un ejemplo de una sentencia print, la cual no imprime nada en papel, más bien muestra un valor. En este caso, el resultado es las palabras Hola, mundo&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Las comillas señalan el comienzo y el final del valor; no aparecen en el resultado.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Alguna gente evalúa la calidad de un lenguaje de programación por la simplicidad del programa “Hola, mundo&quot;. Si seguimos ese criterio, Python cumple con todas sus metas.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/3208939793612871566/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/15-el-primer-programa.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3208939793612871566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3208939793612871566'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/15-el-primer-programa.html' title='1.5. El primer programa'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-2456654494238467553</id><published>2014-02-16T21:17:00.000-08:00</published><updated>2014-02-16T21:17:00.422-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="1.6 glosario"/><category scheme="http://www.blogger.com/atom/ns#" term="bucles"/><category scheme="http://www.blogger.com/atom/ns#" term="cadenas"/><category scheme="http://www.blogger.com/atom/ns#" term="clonar listas"/><category scheme="http://www.blogger.com/atom/ns#" term="encapsulación"/><category scheme="http://www.blogger.com/atom/ns#" term="for"/><category scheme="http://www.blogger.com/atom/ns#" term="pen"/><category scheme="http://www.blogger.com/atom/ns#" term="Pensar como programador"/><category scheme="http://www.blogger.com/atom/ns#" term="pyth"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="Tuplas"/><category scheme="http://www.blogger.com/atom/ns#" term="Un tipo de datos compuesto"/><category scheme="http://www.blogger.com/atom/ns#" term="Valores de una lista"/><title type='text'>1.6. Glosario</title><content type='html'>&lt;p&gt;&lt;br&gt;&lt;strong&gt;solución de problemas:&lt;/strong&gt; El proceso de formular un problema, hallar la solución y expresar esa solución.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;lenguaje de alto nivel:&lt;/strong&gt; Un lenguaje como Python diseñado para ser fácil de leer y escribir para la gente.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;lenguaje de bajo nivel:&lt;/strong&gt; Un lenguaje de programación diseñado para ser fácil de ejecutar para un computador; también se lo llama lenguaje de máquina &quot;o lenguaje ensamblador&quot;.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;portabilidad:&lt;/strong&gt; La cualidad de un programa que le permite ser ejecutado en más de un tipo de computador.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;interpretar:&lt;/strong&gt; Ejecutar un programa escrito en un lenguaje de alto nivel traduciéndolo línea por línea&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;compilar:&lt;/strong&gt; Traducir un programa escrito en un lenguaje de alto nivel a un lenguaje de bajo nivel todo al mismo tiempo, en preparación para la ejecución&lt;br&gt;posterior.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;código fuente:&lt;/strong&gt; Un programa escrito en un lenguaje de alto nivel antes de ser compilado.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;código de objeto:&lt;/strong&gt; La salida del compilador una vez que ha traducido el programa.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;programa ejecutable:&lt;/strong&gt; Otro nombre para el código de objeto que está listo para ejecutarse.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;guión:&lt;/strong&gt; Un programa archivado (que va a ser interpretado).&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;programa:&lt;/strong&gt; Un conjunto de instrucciones que especifica una computación.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;algoritmo:&lt;/strong&gt; Un proceso general para resolver una clase completa de problemas.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;error (bug):&lt;/strong&gt; Un error en un programa.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;depuración:&lt;/strong&gt; El proceso de hallazgo y eliminación de los tres tipos de errores de programación.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;sintaxis:&lt;/strong&gt; La estructura de un programa.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;error sintáctico:&lt;/strong&gt; Un error en un programa que hace que el programa sea imposible de analizar sintácticamente (e imposible de interpretar).&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;error en tiempo de ejecución:&lt;/strong&gt; Un error que no ocurre hasta que el programa ha comenzado a ejecutarse e impide que el programa continúe.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;excepción:&lt;/strong&gt; Otro nombre para un error en tiempo de ejecución.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;error semántico:&lt;/strong&gt; Un error en un programa que hace que ejecute algo que no era lo deseado.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;semántica:&lt;/strong&gt; El significado de un programa.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;lenguaje natural:&lt;/strong&gt; Cualquier lenguaje hablado que evolucionó de forma natural.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;lenguaje formal:&lt;/strong&gt; Cualquier lenguaje diseñado por humanos que tiene un propósito específico, como la representación de ideas matemáticas o programas de computadores; todos los lenguajes de programación son lenguajes formales.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;unidad:&lt;/strong&gt; Uno de los elementos básicos de la estructura sintáctica de un programa, análogo a una palabra en un lenguaje natural.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;análisis sintáctico:&lt;/strong&gt; La examinación de un programa y el análisis de su estructura sintáctica.&lt;br&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;sentencia print:&lt;/strong&gt; Una instrucción que causa que el interprete Python muestre un valor en el monitor.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/2456654494238467553/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/16-glosario.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2456654494238467553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2456654494238467553'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2014/02/16-glosario.html' title='1.6. Glosario'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-6901453848152270490</id><published>2012-08-19T17:59:00.001-07:00</published><updated>2012-08-19T17:59:12.602-07:00</updated><title type='text'>Capítulo 2</title><content type='html'>&lt;h1&gt;Variables, expresiones y&lt;/h1&gt; &lt;h1&gt;sentencias&lt;/h1&gt; &lt;p&gt;&lt;br&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;2.1. Valores y tipos&lt;/h2&gt; &lt;p align=&quot;justify&quot;&gt;El valor es uno de los elementos fundamentales (como por ejemplo una letra o un numero) que manipula un programa. Los valores que hemos visto hasta el momento son 2 (el resultado de sumar 1 + 1) y Hola, mundo.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Estos valores son de distintos tipos: 2 es un entero y Hola, mundo es una cadena, llamada así porque contiene una “cadena&quot; de letras. Usted (y el interprete) puede identificar las cadenas porque están encerradas entre comillas.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;La sentencia print también funciona con enteros:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 11.7%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 56px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print 4&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;4&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Si no esta seguro del tipo que tiene un determinado valor, puede preguntárselo al interprete de Python.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 20.04%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 97px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; type(&lt;span style=&quot;color: #006080&quot;&gt;&quot;Hola, mundo&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;string&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;type(17)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;int&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;No es sorprendente que las cadenas sean de tipo string (cadena en ingles) y los enteros sean de tipo int (por integer en ingles). De forma menos obvia, los números con decimales (separados por medio de un punto en ingles) son de tipo float debido a la representacion de estos numeros en el formato llamado de coma °otante (°oating-point).&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 18.95%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 54px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; type(3.2)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;float&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;¿Que ocurre con los valores como &quot;17&quot; y &quot;3.2&quot;? Parecen numeros, pero están entre comillas como las cadenas.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 20.16%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 133px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; type(&lt;span style=&quot;color: #006080&quot;&gt;&quot;17&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;string&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; type(&lt;span style=&quot;color: #006080&quot;&gt;&quot;3.2&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; &amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;string&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum6&quot;&gt;   6:&lt;/span&gt; Son cadenas.&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;Cuando escriba un entero largo, podría estar tentado de usar comas entre grupos de tres dígitos, como en 1,000,000. Este no es un entero legal en Python, pero es una expresion legal:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 22.47%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 52px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; print 1,000,000&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 1 0 0&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;En fin, no era eso lo que queríamos. Python interpreta 1,000,000 como una lista de tres numeros que debe imprimir. Así que recuerde no insertar comas en sus enteros.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/6901453848152270490/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/capitulo-2.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6901453848152270490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6901453848152270490'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/capitulo-2.html' title='Capítulo 2'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-2768895497401169555</id><published>2012-08-19T17:42:00.001-07:00</published><updated>2012-08-19T17:43:05.511-07:00</updated><title type='text'>2.2. Variables</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Una de las características mas potentes de los lenguajes de programación es la capacidad de manipular variables. Una variable es un nombre que hace referencia a un valor.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;La sentencia de asignación crea nuevas variables y les asigna un valor:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 21.75%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 82px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; mensaje = &lt;span style=&quot;color: #006080&quot;&gt;&quot;Que onda?&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; n = 17&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; pi = &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;3.14159&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Este ejemplo muestra tres asignaciones. La primera de ellas asigna el valor &quot;Que onda?&quot; a una variable nueva, de nombre mensaje. La segunda le da el valor entero 17 a n, y la tercera le da el valor de numero en coma flotante 3.14159 a pi.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Una forma habitual de representar variables sobre el papel es escribir el nombre con una flecha se~nalando al valor de la variable. Este tipo de representación se llama diagrama de estado, ya que muestra en que estado se halla cada una de las variables (considerelo como el \estado de animo&quot; de la variable&quot;).&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;El siguiente diagrama muestra el efecto de las tres sentencias de asignación anteriores:&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR0UyEkXkkyfOPxyGO8OEkCft0hnC9I2sNKgUZEVI06fg6_WeKDI5zMmXHqclxqAwO4-dDQBMbyI5HGZIGPx2vSz12RxAconAJqW5q2Zzgy3PwB8j38CuXW5_hOhTvfgqnTdVkUfhKOxqP/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmuPOWHhl9mF4MoFzk5aOjARXngqGFXZkbkF2RTrwouxbn7Q2hd9ueE3KVO_HhrNdKdeWDEoYuxfSVEa5lgWLyC9qhi1k9HFJZpnH2hJOd_cKLJK23zHPpJCCSZpoMCDBsBUuih-rh87yL/?imgmax=800&quot; width=&quot;280&quot; height=&quot;121&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;La sentencia print tambien funciona con variables.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 16.75%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 137px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print mensaje&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #006080&quot;&gt;&quot;Que onda?&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;n&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;17&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; print pi&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;3.14159&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;En cada caso, el resultado es el valor de la variable. Las variables tambien tienen tipo. De nuevo, podemos preguntar al interprete lo que son.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 14.7%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 152px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; type(mensaje)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;string&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;type(n)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;int&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;gt;&amp;gt;&amp;gt; type(pi)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&amp;lt;type &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #006080&quot;&gt;&#39;float&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;El tipo de una variable es el tipo del valor al que se refiere.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/2768895497401169555/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/22-variables.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2768895497401169555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/2768895497401169555'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/22-variables.html' title='2.2. Variables'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmuPOWHhl9mF4MoFzk5aOjARXngqGFXZkbkF2RTrwouxbn7Q2hd9ueE3KVO_HhrNdKdeWDEoYuxfSVEa5lgWLyC9qhi1k9HFJZpnH2hJOd_cKLJK23zHPpJCCSZpoMCDBsBUuih-rh87yL/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-3640910335428531767</id><published>2012-08-19T17:38:00.001-07:00</published><updated>2012-08-19T17:38:56.937-07:00</updated><title type='text'>2.3. Nombres de variables y palabras reservadas</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Como norma general, los programadores eligen nombres significativos para sus variables: esto permite documentar para que se usa la variable.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Los nombres de las variables pueden tener una longitud arbitraria. Pueden estar formados por letras y números, pero deben comenzar con una letra. Aunque es aceptable usar mayúsculas, por convención no lo hacemos. Si lo hace, recuerde que la distinción es importante: Bruno y bruno son dos variables diferentes.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;El guion bajo ( ) también es legal y se utiliza a menudo para separar nombres con múltiples palabras, como mi nombre o precio del cafe colombiano.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Si intenta darle a una variable un nombre ilegal, obtendrá un error de sintaxis.&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 37.62%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 161px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; 76trombones = &lt;span style=&quot;color: #006080&quot;&gt;&quot;gran desfile&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; SyntaxError: invalid &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; syntax&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; mas$ = 1000000&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; SyntaxError: invalid &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum6&quot;&gt;   6:&lt;/span&gt; syntax&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum7&quot;&gt;   7:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; = &lt;span style=&quot;color: #006080&quot;&gt;&quot;Curso de Programacion 101&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum8&quot;&gt;   8:&lt;/span&gt; SyntaxError: &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum9&quot;&gt;   9:&lt;/span&gt; invalid syntax&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;&lt;strong&gt;76trombones&lt;/strong&gt; es ilegal porque no comienza por una letra. mas$ es ilegal porque contiene un caracter ilegal, el signo del dolar. Pero ¿que tiene de malo class?&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Resulta que class es una de las palabras reservadas de Python. El lenguaje usa las palabras reservadas para definir sus reglas y estructura, y no pueden usarse como nombres de variables.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Python tiene 28 palabras reservadas:&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 53.07%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 94px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;and     &lt;span style=&quot;color: #0000ff&quot;&gt;continue&lt;/span&gt;     &lt;span style=&quot;color: #0000ff&quot;&gt;else&lt;/span&gt;     &lt;span style=&quot;color: #0000ff&quot;&gt;for&lt;/span&gt;    import     not     raise&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;assert  def          except   from   in         or      &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;break&lt;/span&gt;   del          exec     global is         pass    &lt;span style=&quot;color: #0000ff&quot;&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt;   elif         finally  &lt;span style=&quot;color: #0000ff&quot;&gt;if&lt;/span&gt;     lambda     print   &lt;span style=&quot;color: #0000ff&quot;&gt;while&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Tal vez quiera mantener esta lista a mano. Si el interprete se queja de alguno de sus nombres de variable, y usted no sabe por que, compruebe si esta en esta lista.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/3640910335428531767/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/23-nombres-de-variables-y-palabras.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3640910335428531767'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3640910335428531767'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/23-nombres-de-variables-y-palabras.html' title='2.3. Nombres de variables y palabras reservadas'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-4039202990423576077</id><published>2012-08-19T17:32:00.001-07:00</published><updated>2012-08-19T17:32:38.207-07:00</updated><title type='text'>2.4. Sentencias</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Una sentencia es una instrucción que puede ejecutar el interprete de Python.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Hemos visto dos tipos de sentencias: print y la asignación.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Cuando usted escribe una sentencia en la l³nea de comandos, Python la ejecuta y muestra el resultado, si lo hay. El resultado de una sentencia print es un valor.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Las sentencias de asignación no entregan ningún resultado.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Normalmente un guion contiene una secuencia de sentencias. Si hay mas de una sentencia, los resultados aparecen de uno en uno tal como se van ejecutando las sentencias.&lt;br&gt;Por ejemplo, el guion&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 22.96%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 111px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; print 1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; x = 2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; print x&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; prsenta la salida&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; 1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum6&quot;&gt;   6:&lt;/span&gt; 2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;De nuevo, la sentencia de asignacion no produce ninguna salida.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/4039202990423576077/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/24-sentencias.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4039202990423576077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4039202990423576077'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/24-sentencias.html' title='2.4. Sentencias'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-7539100664302334382</id><published>2012-08-19T17:30:00.001-07:00</published><updated>2012-08-19T17:30:17.125-07:00</updated><title type='text'>2.5. Evaluar expresiones</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Una expresión es una combinación de valores, variables y operadores. Si teclea una expresión en la línea de comandos, el interprete la evalúa y muestra el resultado:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 15.41%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 66px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; 1 + 1&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;Un valor, y también una variable, se considera una expresión por sí mismo.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 13.45%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 86px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; 17&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 17&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; x&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; 2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;Para complicar las cosas, evaluar una expresion no es del todo lo mismo que imprimir un valor.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 27.05%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 122px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; mensaje = &lt;span style=&quot;color: #006080&quot;&gt;&quot;Que onda?&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; mensaje&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&quot;Que &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; onda?&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; print mensaje&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum6&quot;&gt;   6:&lt;/span&gt; Que onda?&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Cuando Python muestra el valor de una expresion, usa el mismo formato que usted usaría para introducir un valor. En el caso de las cadenas, eso significa que incluye las comillas. Pero la sentencia print imprime el valor de la expresion, lo que en este caso es el contenido de la cadena.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;En un guion, una expresion sin mas es una sentencia valida, pero no hace nada.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;El guion 17 3.2 &quot;Hola, mundo&quot; 1 + 1&lt;br&gt;no presenta ninguna salida. ¿Como cambiaría usted el guion para mostrar los valores de estas cuatro expresiones?&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/7539100664302334382/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/25-evaluar-expresiones.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7539100664302334382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7539100664302334382'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/25-evaluar-expresiones.html' title='2.5. Evaluar expresiones'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-4862523962263117880</id><published>2012-08-19T17:26:00.001-07:00</published><updated>2012-08-19T17:26:58.835-07:00</updated><title type='text'>2.6. Operadores y expresiones</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Los operadores son símbolos especiales que representan cálculos simples, como la suma y la multiplicación. Los valores que usa el operador se llaman operandos.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Las siguientes expresiones son legales en Python y su significado es mas o menos claro:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 64.89%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 46px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; 20+32     hora-1     hora*60+minuto     minuto/60     5**2     (5+9)*(15-7)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;Los símbolos +, -, /, y el uso de los parentesis para el agrupamiento, se usan todos de la misma forma que en matematicas. El asterisco (*) es el signo de multiplicación y ** el s³mbolo para exponenciacion.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Cuando aparece el nombre de una variable en el lugar de un operando, se sustituye con su valor antes de realizar la operacion.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;La suma, resta, multiplicacion y exponenciacion hacen lo esperado, pero la división le puede sorprender. La operacion que sigue tiene un resultado inesperado:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 19.22%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 72px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; minuto = 59&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; minuto/60&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; 0&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;El valor de la variable minuto es 59, y 59 dividido entre 60 es 0.98333 y no 0. El motivo de la discrepancia reside en que &lt;strong&gt;Python&lt;/strong&gt; esta llevando a cabo una división de enteros.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Cuando ambos operandos son enteros, el resultado ha de ser tambien un entero; por convencion, la division de enterios simpre se redondea a la baja, incluso en casos como estos en los que el siguiente entero esta muy proximo.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Una alternativa posible en este caso es el calculo de un porcentaje y no el de una fracción:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 20.27%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 54px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; minuto*100/60&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 98&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;De nuevo se redondea el resultado a la baja, pero al menos ahora la respuesta es aproximadamente correcta. Otra alternativa es la division de coma flotante, que veremos en el Capítulo 3.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/4862523962263117880/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/26-operadores-y-expresiones.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4862523962263117880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4862523962263117880'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/26-operadores-y-expresiones.html' title='2.6. Operadores y expresiones'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-8004986368334504461</id><published>2012-08-19T16:53:00.001-07:00</published><updated>2012-08-19T16:56:32.255-07:00</updated><title type='text'>2.7. El orden de las operaciones</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Cuando aparece mas de un operador en una expresión, el orden de evaluación depende de las reglas de precedencia. &lt;strong&gt;Python&lt;/strong&gt; sigue las mismas reglas de precedencia que los propios matemáticos para sus operaciones matemáticas.&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;div align=&quot;justify&quot;&gt;Los ingleses usan el acrónimo &lt;strong&gt;PEMDAS&lt;/strong&gt; como regla parea recordar el orden de las operaciones:&lt;/div&gt; &lt;li&gt; &lt;div align=&quot;justify&quot;&gt;Paréntesis: tienen la precedencia mas alta y pueden usarse para forzar que una expresión se evalué en el orden que queramos nosotros.&lt;/div&gt; &lt;li&gt; &lt;div align=&quot;justify&quot;&gt;Puesto que las expresiones entre paréntesis se evalúan primero, 2 * (3-1) es igual a 4, y (1+1)**(5-2) es igual a 8. También puede usar paréntesis para que una expresión sea mas legible; por ejemplo (minuto * 100) / 60, aunque el resultado no cambie de todas formas.&lt;/div&gt; &lt;li&gt; &lt;div align=&quot;justify&quot;&gt;Exponenciación tiene la siguiente precedencia mas alta; as³ pues 2**1+1 es igual a 3 y no a 4, y 3*1**3 es igual a 3 y no a 27.&lt;/div&gt; &lt;li&gt; &lt;div align=&quot;justify&quot;&gt;La Multiplicación y la División tienen la misma precedencia, que es mas alta que la de la Adición y la Sustracción, que tienen también la misma precedencia. Por tanto 2*3-1 devuelve 5 y no 4, y 2/3-1 da -1, y no 1 (recuerde que en la división de enteros 2/3 da 0).&lt;br&gt;Los operadores que tienen la misma precedencia se evalúan de izquierda a derecha. As³, en la expresión minuto*100/60, tiene lugar primero la&lt;br&gt;multiplicación, devolviendo &lt;strong&gt;tt&lt;/strong&gt; 5900/60, que a su vez da como resultado 98. &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p align=&quot;justify&quot;&gt;Si las operaciones se hubiesen realizado de derecha a izquierda, el resultado habría sido 59/1 que da 59, y que es incorrecto.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/8004986368334504461/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/27-el-orden-de-las-operaciones.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/8004986368334504461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/8004986368334504461'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/27-el-orden-de-las-operaciones.html' title='2.7. El orden de las operaciones'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-6750488925610913789</id><published>2012-08-19T16:51:00.001-07:00</published><updated>2012-08-19T16:51:03.670-07:00</updated><title type='text'>2.8. Las operaciones sobre cadenas</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;En general no es posible realizar operaciones matemáticas con cadenas, incluso si las cadenas parecen números. Las siguientes sentencias son ilegales (suponiendo que mensaje sea de tipo string) &lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 39.12%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 39px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; mensaje-1 &lt;span style=&quot;color: #006080&quot;&gt;&quot;Hola&quot;&lt;/span&gt;/123 mensaje*&lt;span style=&quot;color: #006080&quot;&gt;&quot;Hola&quot;&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&quot;15&quot;&lt;/span&gt;+2&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;Es curioso que el operador + funcione con cadenas, aunque no haga exactamente lo que usted esperar³a. Para cadenas, el operador + representa la concatenación, lo que significa que se unen los dos operandos uniéndolos extremo con&lt;br&gt;extremo. Por ejemplo:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 32.01%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 85px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; fruta = &lt;span style=&quot;color: #006080&quot;&gt;&quot;platano&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; bizcochoBueno = &lt;span style=&quot;color: #006080&quot;&gt;&quot; pan de leche&quot;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; print fruta + &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; bizcochoBueno&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;La salida del programa es platano pan de leche. El espacio delante de pan es parte de la cadena, y es necesario para introducir el espacio que separa las cadenas concatenadas.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;El operador * tambien funciona con cadenas; lleva a cabo la repeticion. Por ejemplo &#39;Chiste&#39;*3 es &#39;ChisteChisteChiste&#39;. Uno de los operandos ha de ser una cadena, el otro ha de ser un entero.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Por un lado, esta interpretacion de + y * cobra sentido por analogía con la suma y la multimplicacion. Igual que 4*3 es equivalente a 4+4+4, esperamos que &#39;Chiste&#39;*3 sea lo mismo que &#39;Chiste&#39;+&#39;Chiste&#39;+&#39;Chiste&#39;, y así es. Por otro lado, la concatenacion y la repeticion son de alguna manera muy diferentes de la adicion y la multiplicacion de enteros. &lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;¿Puede encontrar una propiedad que&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;¿tienen la suma y la multiplicacion de enteros y que no tengan la concatenación y la repeticion de cadenas?&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/6750488925610913789/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/28-las-operaciones-sobre-cadenas.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6750488925610913789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6750488925610913789'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/28-las-operaciones-sobre-cadenas.html' title='2.8. Las operaciones sobre cadenas'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-3659838314132777126</id><published>2012-08-19T16:47:00.001-07:00</published><updated>2012-08-19T16:47:37.536-07:00</updated><title type='text'>2.9. Composición</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Hasta ahora hemos examinado los elementos de un programa (variables, expresiones y sentencias) por separado, sin hablar de como combinarlos.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Una de las características mas útiles de los lenguajes de programación es su capacidad de tomar peque~nos bloques de construcción y ensamblarlos. Por ejemplo, sabemos como sumar números y como imprimirlos; resulta que podemos hacer las dos cosas a un tiempo:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 19.95%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 53px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; print 17 + 3&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 20&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;En realidad, no debemos decir “al mismo tiempo”, puesto que en realidad la suma tiene que realizarse antes de la impresion, pero la cuestion es que cualquier expresión relacionada con numeros, cadenas y variables puede usarse dentro de una sentencia print. Ya hemos visto un ejemplo de ello:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 54.94%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 38px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; print &lt;span style=&quot;color: #006080&quot;&gt;&quot;Numero de minutos desde la medianoche: &quot;&lt;/span&gt;, hora*60+minuto&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/3659838314132777126/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/29-composicion.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3659838314132777126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3659838314132777126'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/29-composicion.html' title='2.9. Composición'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-6961050907400642225</id><published>2012-08-19T16:44:00.001-07:00</published><updated>2012-08-19T16:44:51.257-07:00</updated><title type='text'>2.10. Los comentarios</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Conforme los programas van creciendo de tamaño y complicándose, se vuelven mas complicados de leer. Los lenguajes formales son densos y con frecuencia es difícil observar un trozo de código y averiguar lo que hace, o por que lo hace.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Por ello es una buena idea a~nadir notas a su programa que expliquen, en un lenguaje natural, que hace el programa. Estas notas se llaman comentarios y se marcan con el símbolo #:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 73.59%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 35px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; # calcula el porcentaje de la hora que ha pasado ya porcentaje = (minuto * 100) / 60&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;En este caso, el comentario aparece en una línea propia. También puede poner comentarios al final de otras líneas: &lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 54.83%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 42px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; porcentaje = (minuto * 100) / 60 # ojo: división de enteros&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Todo lo que va del # al final de la línea se ignora (no tiene efecto sobre el programa). El mensaje esta destinado al programador, o a futuros programadores que podrían tener que usar el código. En este caso avisa al lector sobre el sorprendente comportamiento de la división de enteros.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/6961050907400642225/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/210-los-comentarios.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6961050907400642225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6961050907400642225'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/210-los-comentarios.html' title='2.10. Los comentarios'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-3333356864355601177</id><published>2012-08-19T16:40:00.001-07:00</published><updated>2012-08-19T16:40:04.958-07:00</updated><title type='text'>2.11. Glosario</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;valor&lt;/strong&gt;: un numero o cadena (o cualquier otra cosa que se especifique posteriormente) que puede almacenarse en una variable o calcularse en una expresión.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;tipo:&lt;/strong&gt; un conjunto de valores. El tipo de un valor determina como puede usarse en las expresiones. Hasta ahora, los tipos que hemos visto son enteros (tipo int), números de coma flotante (tipo float) y cadenas (tipo string).&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;coma flotante:&lt;/strong&gt; un formato para representar números con decimales.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;variable: nombre que hace referencia a un valor.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;sentencia&lt;/strong&gt;: es una porción de código que representa una orden o acción. Hasta ahora, las sentencias que hemos vistos son las asignaciones y las sentencias print.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;asignación: sentencia que asigna un valor a una variable.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;diagrama de estado&lt;/strong&gt;: representación grafica de un conjunto de variables y de los valores a los que se refiere.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;palabra reservada&lt;/strong&gt;: es una palabra clave que usa el compilador para analizar sintacticamente los programas. No pueden usarse palabras reservadas, por ejemplo if, def y while como nombres de variables.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;operador&lt;/strong&gt;: un símbolo especial que representa un calculo sencillo, como la suma, la multiplicación o la concatenación de cadenas.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;operando&lt;/strong&gt;: uno de los valores sobre los que actúa un operador.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;expresión&lt;/strong&gt;: una combinación de variables, operadores y valores. Dicha combinación representa un único valor como resultado.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;evaluar&lt;/strong&gt;: simplificar una expresión ejecutando las operaciones para entregar un valor único.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;división de enteros&lt;/strong&gt;: es una operación que divide un entero entre otro y devuelve un entero. La división de enteros devuelve solo el numero entero de veces que el numerador es divisible por en denominador, y descarta el resto.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;reglas de precedencia&lt;/strong&gt;: la serie de reglas que especifican el orden en el que las expresiones con mutiles operadores han de evaluarse.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;concatenar&lt;/strong&gt;: unir dos operandos extremo con extremo.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;composición:&lt;/strong&gt; la capacidad de combinar expresiones sencillas y sentencias hasta crear sentencias y expresiones compuestas, con el fin de representar cálculos complejos de forma concisa.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;comentario&lt;/strong&gt;: un segmento de información en un programa, destinado a otros programadores (o cualquiera que lea el código fuente) y que no tiene efecto sobre la ejecución del programa.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/3333356864355601177/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/211-glosario.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3333356864355601177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/3333356864355601177'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/211-glosario.html' title='2.11. Glosario'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-7060156084045937256</id><published>2012-08-19T16:25:00.001-07:00</published><updated>2012-08-19T16:25:18.915-07:00</updated><title type='text'>Capítulo 3</title><content type='html'>&lt;h1&gt;Funciones&lt;/h1&gt; &lt;p&gt;&lt;br&gt; &lt;h2&gt;3.1. Llamadas a funciones&lt;/h2&gt; &lt;p align=&quot;justify&quot;&gt;Ya hemos visto un ejemplo de una llamada a una función:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 20.41%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 47px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; type(&lt;span style=&quot;color: #006080&quot;&gt;&quot;32&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;lt;type &lt;span style=&quot;color: #006080&quot;&gt;&#39;string&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;El nombre de la funcion es &lt;strong&gt;type&lt;/strong&gt;, y muestra el tipo de un valor o de una variable.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;El &lt;strong&gt;valor&lt;/strong&gt; o &lt;strong&gt;variable&lt;/strong&gt;, llamado el argumento de la función, ha de estar encerrado entre parentesis. Es habitual decir que una función “toma&quot; un argumento y ”devuelve&quot; un resultado. El resultado se llama valor de retorno.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;En lugar de imprimir el valor de retorno, podemos asignarselo a una variable.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 26.08%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 78px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; nereida = type(&lt;span style=&quot;color: #006080&quot;&gt;&quot;32&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; print nereida&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &amp;lt;type &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&#39;string&#39;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Otro ejemplo mas: la funcion &lt;strong&gt;id&lt;/strong&gt; toma como argumento un valor o una variable y devuelve un entero que actua como identificador unico de ese valor.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 18.9%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 107px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; id(3)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 134882108&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; yanira = 3&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; id(yanira)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum6&quot;&gt;   6:&lt;/span&gt; 134882108&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Cada valor tiene un id, que es un valor unico relacionado con donde se almacena en la memoria del computador. El &lt;strong&gt;id&lt;/strong&gt; de una variable es el &lt;strong&gt;id&lt;/strong&gt; del valor al que hace referencia.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/7060156084045937256/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/capitulo-3.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7060156084045937256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7060156084045937256'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/capitulo-3.html' title='Capítulo 3'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-4788725242462187235</id><published>2012-08-19T16:20:00.001-07:00</published><updated>2012-08-19T16:20:24.571-07:00</updated><title type='text'>3.2. Conversión de tipos</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Python proporciona una colección de funciones internas que convierten valores de un tipo a otro. La función &lt;strong&gt;int&lt;/strong&gt; toma un valor y lo convierte a un entero, si es posible, o da un error si no es posible.&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 27.2%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 114px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;(&lt;span style=&quot;color: #006080&quot;&gt;&quot;32&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 32&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;(&lt;span style=&quot;color: #006080&quot;&gt;&quot;Hola&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; ValueError: invalid &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum5&quot;&gt;   5:&lt;/span&gt; literal &lt;span style=&quot;color: #0000ff&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;(): Hola&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;int&lt;/strong&gt; tambien convierte valores de coma flotante a enteros, pero recuerde que siempre redondea hacia abajo:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 20.13%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 65px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;(3.99999)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 3&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;La funcion float que convierte enteros y cadenas en numeros en coma flotante:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 25.1%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 94px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000ff&quot;&gt;float&lt;/span&gt;(32)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 32.0&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000ff&quot;&gt;float&lt;/span&gt;(&lt;span style=&quot;color: #006080&quot;&gt;&quot;3.14159&quot;&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; 3.14159&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Finalmente, esta la funcion str, que convierte a tipo string:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 19.2%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 82px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; str(32)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&#39;32&#39;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; str(3.14149)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum4&quot;&gt;   4:&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&#39;3.14149&#39;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;Pudiera parecer extraño que &lt;strong&gt;Python&lt;/strong&gt; distinga entre el valor entero 1 y el valor&amp;nbsp; de coma flotante 1.0. Tal vez representen el mismo numero, pero pertenecen a tipos distintos. El motivo es que se representan de forma distinta dentro del computador.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/4788725242462187235/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/32-conversion-de-tipos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4788725242462187235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/4788725242462187235'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/32-conversion-de-tipos.html' title='3.2. Conversión de tipos'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-7711622400546781845</id><published>2012-08-19T16:15:00.001-07:00</published><updated>2012-08-19T16:16:21.858-07:00</updated><title type='text'>3.3. Coerción de tipos</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Ahora que ya sabemos convertir entre tipos, tenemos otra forma de enfrentarnos a la división de enteros. Volviendo al ejemplo del capítulo anterior, suponga que queremos calcular que fracción de una hora había transcurrido. La expresión mas obvia, &lt;strong&gt;minuto / 60&lt;/strong&gt;, realiza una división de enteros, por lo que el resultado es siempre 0, incluso 59 minutos después de la hora.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Una alternativa es convertir minuto a tipo float (coma flotante) y luego efectuar una división de coma flotante:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 27.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 78px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; minuto = 59&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000ff&quot;&gt;float&lt;/span&gt;(minuto) / 60.0&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; 0.983333333333&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;O bien podemos sacar provecho de las reglas de la conversion automatica de tipos, llamada coercion de tipos. Para los operadores matematicos, si uno de los operandos matematicos es tipo float, el otro se convierte automáticamente en float.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 20.92%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 77px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; minuto = 59&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; minuto / 60.0&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; 0.983333333333&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Al usar un denomidador que es &lt;strong&gt;float&lt;/strong&gt;, obligamos a &lt;strong&gt;Python&lt;/strong&gt; a hacer division de&lt;strong&gt; coma flotante&lt;/strong&gt;.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/7711622400546781845/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/33-coercion-de-tipos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7711622400546781845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/7711622400546781845'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/33-coercion-de-tipos.html' title='3.3. Coerción de tipos'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6557679628416245687.post-6171316714273482129</id><published>2012-08-19T16:10:00.001-07:00</published><updated>2012-08-19T16:10:11.440-07:00</updated><title type='text'>3.4. Funciones matemáticas</title><content type='html'>&lt;p align=&quot;justify&quot;&gt;Es posible que ya haya visto usted en matemáticas funciones como sin (seno) y log, y que haya aprendido a evaluar expresiones como &lt;strong&gt;sin(pi/2) y log(1/x).&lt;/strong&gt; &lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Primero evalúa la expresión entre paréntesis, (el argumento). Por ejemplo, pi/2 es aproximadamente 1.571, y 1/x es 0.1 (si x es igual a 10.0).&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Luego evalúa la función en sí misma, bien mirándola en una tabla, bien llevando a cabo diversos cálculos. El sin (seno) de 1.571 es 1, y el log de 0.1 es –1 (suponiendo que log indique el logaritmo de base 10).&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Este proceso puede aplicarse repetidamente para evaluar expresiones mas complicadas como log(1/sin(pi/2)). Primero evaluamos el argumento de la función mas interna, luego se evalúa la función, y así sucesivamente.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;&lt;strong&gt;Python&lt;/strong&gt; dispone de un modulo matemático que proporciona la mayor³a de las funciones matemáticas habituales. Un modulo es un archivo que contiene una colección de funciones agrupadas juntas.&lt;/p&gt; &lt;p align=&quot;justify&quot;&gt;Antes de poder usar las funciones de un modulo, tenemos que importarlo:&lt;br&gt;&lt;/p&gt; &lt;div align=&quot;center&quot;&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 21.2%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 35px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt; &lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt;import math&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;Para llamar a una de las funciones, tenemos que especificar el nombre del modulo y el nombre de la funcion, separados por un punto. A esto se le llama notación de punto:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 34.11%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 69px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; decibelio = math.log10 (17.0)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; angulo = 1.5&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; altura = math.sin(angulo)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;&lt;br&gt;La primera sentencia da a decibelio el valor del logaritmo de 17, en base 10.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Hay tambien una funcion llamada log que toma logaritmos en base e.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;La tercera sentencia halla el seno del valor de la variable angulo. sin y las otras funciones trigonometricas (cos, tan, etc.) toman sus argumentos en radianes.&lt;/p&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;Para convertir de grados a radianes, puede dividir por 360 y multiplicar por 2*pi. Por ejemplo, para hallar el seno de 45 grados, calcule primero el ángulo en radianes y luego halle el seno:&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 37.47%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 84px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; grados = 45&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; angulo = grados * 2 * math.pi / 360.0&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum3&quot;&gt;   3:&lt;/span&gt; math.sin(angulo)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align=&quot;justify&quot;&gt;La constante pi tambien es parte del modulo &lt;strong&gt;math&lt;/strong&gt;. Si se sabe la geometría, puede verificar el resultado comparandolo con el de la raíz cuadrada de 2, dividida entre 2.&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;div align=&quot;center&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 24.38%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 54px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum1&quot;&gt;   1:&lt;/span&gt; &amp;gt;&amp;gt;&amp;gt; math.sqrt(2) / 2.0&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot;&gt;&lt;span style=&quot;color: #606060&quot; id=&quot;lnum2&quot;&gt;   2:&lt;/span&gt; 0.707106781187&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://pensandocomoprogramador.blogspot.com/feeds/6171316714273482129/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/34-funciones-matematicas.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6171316714273482129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6557679628416245687/posts/default/6171316714273482129'/><link rel='alternate' type='text/html' href='http://pensandocomoprogramador.blogspot.com/2012/08/34-funciones-matematicas.html' title='3.4. Funciones matemáticas'/><author><name>Julio Cesar</name><uri>http://www.blogger.com/profile/17380076930325810236</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='-1' height='-1' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYd0TrzIWwbiuVVBZcDDqJ3-MGcigRFsts7iesaykpIv5ish5BqE8QApH5OpX0PVyD636T5kA2cxyOTAiX2h0BCxJSRwbj6cJNMoI6uvwVdXSSnhXbd2pyEolie8F32fdBV341W1e_p5qhgh6gQYXVQsQ1a1ASCRe5NEA5sDpJZ9wHTY/s1600/739264414_10234651969021474_9180845868380681535_n.jpg'/></author><thr:total>0</thr:total></entry></feed>