create account

Tutorial #2 Python: Comentarios y Operadores Aritméticos by gabox

View this thread on: hive.blogpeakd.comecency.com
· @gabox · (edited)
$29.01
Tutorial #2 Python: Comentarios y Operadores Aritméticos
#### What Will I Learn?

- Use comments in the code
- Arithmetic operators in Python
- Application of arithmetic formula with variables

#### Requirements

- Basic knowledge of programming
- Have python installed
- Have Sublime Text installed (optional)

#### Difficulty

- Basic

#### Tutorial Contents

<center>![portadas.jpg](https://steemitimages.com/DQmNyTTkERkcdQ66yGb7tAGgucFTgSyKtrRTLSjbnQEg6ba/portadas.jpg)
<a href="https://imgur.com/gallery/ciwlCWa"><strong>Fuente</strong></a></center>
<div class="text-justify"><p>A través de este tutorial aprenderemos como usar los comentarios y operadores aritméticos dentro del lenguaje Python, es importante destacar que necesitamos los conocimientos previos del tutorial número 1, si aún no has pasado por él te recomiendo visitarlo, el link del mismo se encuentra al final del post.</p></div>

<div class="text-justify"><p>Antes de entrar en código repasemos conceptos básicos dentro de la programación, para entender de manera clara y precisa para que son los comentarios y operadores aritméticos dentro de nuestro código de programación.</p></div>

<div class="text-justify"><p>Los comentarios nos sirven como bien dice la palabra para dejar oraciones, palabras o frases que nos permiten recordar la función específica que está ejecutando el código a partir de esa línea, esto hará una lectura más fácil tanto para nosotros como para cualquier persona, a veces es complicado leer el código de un programa realizado por un tercero si el mismo no tiene comentarios, por lo que es importante resaltar en los mismos las funcionabilidades por si necesitamos en un futuro cierta función en el mismo.</p></div>

# Comentarios

<div class="text-justify"><p>Para realizar comentarios en Python debemos de usar el siguiente símbolo “#” seguido de un espacio y luego la palabra o frases a colocar, es muy importante seguir esta sintaxis para evitar futuros errores en nuestros códigos, como ejemplo podríamos tomar la siguiente línea:</p></div>

<code># Operadores Mátematicos</code>

![1.jpg](https://steemitimages.com/DQmb95t17HtFskPmkSbYPVjcjQF69Ja6zi8fWYbq7V4zgJf/1.jpg)

<div class="text-justify"><p>Es importante destacar que en los comentarios podemos usar cualquier tipo de carácter especial, acentos espacios, es decir todo lo que deseamos colocar será válido, esto no es recomendable hacerlo cuando estamos fuera de la línea de comentarios.</p></div>

# Operadores Aritméticos

<div class="text-justify"><p>Como bien su nombre indica son todos aquellos operadores matemáticos que nos permiten realizar diferentes operaciones entre números, en este caso vamos a ver cómo podemos sumar, restar, multiplicar, dividir, hacer una operación tipo modulo o un exponente, los signos correspondientes a estas operaciones son:</p></div>

- Suma: +
- Resta: -
- Multiplicación: *
- División: /
- División entera (si queremos que el resultado sea un numero entero): //
- Módulo (residuo de una división): %
- Exponente: **

<div class="text-justify"><p>Ahora aplicaremos esto en código asignando valores a distintas variables, el orden será como en la lista anterior</p></div>

<code>suma = 3 + 6</code>
<code>resta = 9 - 3</code>
<code>multiplicar = 5 * 5</code>
<code>dividir = 10 / 2</code>
<code>modulo = 9 % 2</code>
<code>exponente = 4 ** 5</code>

Este sería el resultado aplicando estos códigos en Python:

![2.jpg](https://steemitimages.com/DQmRi9Rz4p4u7CMnZ9DwcUzLV2oHSLM214HkakC5iCAKzAj/2.jpg)

<div class="text-justify"><p>Ahora si queremos ver el resultado de cada una de las operaciones debemos usar nuestro comando print para cada una de las variables, mostrare un ejemplo para una de ellas, pero como ejercicio realízalo para todas las que creamos.</p></div>

<code>print (suma)</code>

El resultado final para todas nuestras variables seria el siguiente:

![3.jpg](https://steemitimages.com/DQmew9peMZ8RnHqqpGCVhNpZmoQqV7iVoC7dMWVFMeKR6bj/3.jpg)

<div class="text-justify"><p>Ahora con estos conocimientos podemos hacer distintos cálculos de fórmulas matemáticas, en este caso haremos este pequeño ejercicio, vamos a calcular el área de un triángulo, recordemos que la fórmula para esto es base x altura entre 2, para esto identificamos nuestras variables de la siguiente manera:</p></div>

<center>http://www.universoformulas.com/imagenes/formulas/matematicas/geometria/area-triangulo-base-altura-conocidas.jpg
<a href="http://www.universoformulas.com/matematicas/geometria/area-triangulo/"><strong>Fuente</strong></a></center>

<code>base = 8</code>
<code>altura = 4</code>
<code>area = (base * altura) / 2</code>
<code>print (area)</code>

Obtendremos el siguiente resultado:

![4.jpg](https://steemitimages.com/DQmNvR3ZqCYasMUCbG6MgYNhDWf2zUyW4nanvFiHBQg9YJA/4.jpg)

<div class="text-justify"><p>Sin embargo, cuando un programa lo ejecuta un usuario el coloca los valores que le interesen, en este caso nosotros los programadores somos los que estamos dándole el valor en las variables, es así como en el siguiente tutorial vamos a explicar cómo pedir y almacenar datos del usuario para la realización de distintos programas.
De esta manera termina este segundo tutorial, recuerden que si tienen alguna duda pueden usar la caja de comentarios, ¡Nos vemos en el próximo!</p></div>

#### Curriculum
To understand optimally everything explained it is advisable to see these tutorials

- [Tutorial #1 Python: Declaración de variables y Tipo de datos](https://steemit.com/utopian-io/@gabox/tutorial-1-python-declaracion-de-variables-y-tipo-de-datos)

    

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@gabox/tutorial-2-python-comentarios-y-operadores-aritmeticos">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorgabox
permlinktutorial-2-python-comentarios-y-operadores-aritmeticos
categoryutopian-io
json_metadata{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":81598961,"name":"cpython","full_name":"python/cpython","html_url":"https://github.com/python/cpython","fork":false,"owner":{"login":"python"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","spanish","cervantes","programacion","venezuela"],"links":["https://imgur.com/gallery/ciwlCWa","http://www.universoformulas.com/matematicas/geometria/area-triangulo/","https://steemit.com/utopian-io/@gabox/tutorial-1-python-declaracion-de-variables-y-tipo-de-datos","https://utopian.io/utopian-io/@gabox/tutorial-2-python-comentarios-y-operadores-aritmeticos"],"image":["https://steemitimages.com/DQmNyTTkERkcdQ66yGb7tAGgucFTgSyKtrRTLSjbnQEg6ba/portadas.jpg","https://steemitimages.com/DQmb95t17HtFskPmkSbYPVjcjQF69Ja6zi8fWYbq7V4zgJf/1.jpg","https://steemitimages.com/DQmRi9Rz4p4u7CMnZ9DwcUzLV2oHSLM214HkakC5iCAKzAj/2.jpg","https://steemitimages.com/DQmew9peMZ8RnHqqpGCVhNpZmoQqV7iVoC7dMWVFMeKR6bj/3.jpg","http://www.universoformulas.com/imagenes/formulas/matematicas/geometria/area-triangulo-base-altura-conocidas.jpg","https://steemitimages.com/DQmNvR3ZqCYasMUCbG6MgYNhDWf2zUyW4nanvFiHBQg9YJA/4.jpg"],"moderator":{"account":"favcau","time":"2018-01-27T22:59:37.417Z","reviewed":true,"pending":false,"flagged":false}}
created2018-01-27 06:40:51
last_update2018-01-27 22:59:36
depth0
children8
last_payout2018-02-03 06:40:51
cashout_time1969-12-31 23:59:59
total_payout_value20.833 HBD
curator_payout_value8.177 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,703
author_reputation309,708,176,468,307
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,665,234
net_rshares4,161,735,865,676
author_curate_reward""
vote details (25)
@artemisjane26 ·
Chevere @gabox muy educativo vale
properties (22)
authorartemisjane26
permlinkre-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180128t052036019z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["gabox"],"app":"steemit/0.1"}
created2018-01-28 05:20:39
last_update2018-01-28 05:20:39
depth1
children1
last_payout2018-02-04 05:20:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length33
author_reputation1,977,098,904,707
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,916,264
net_rshares0
@gabox ·
Gracias @artemisjane26, mi intención es ayudar aquellos que se estén iniciando en el mundo de la programación!!
properties (22)
authorgabox
permlinkre-artemisjane26-re-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180128t073527053z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["artemisjane26"],"app":"steemit/0.1"}
created2018-01-28 07:07:24
last_update2018-01-28 07:07:24
depth2
children0
last_payout2018-02-04 07:07:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length111
author_reputation309,708,176,468,307
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,934,029
net_rshares0
@favcau ·
$1.68
Thank you for the contribution. It has been approved.
* Next time, try to improve your tutorials, add more content. Comments and arithmetic operators is really little for a tutorial. Also you didn't mention the multiline comment

You can contact us on [Discord](https://discord.gg/uTyJkNm).
**[[utopian-moderator]](https://utopian.io/moderators)**
👍  
properties (23)
authorfavcau
permlinkre-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180127t230005099z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-27 23:00:18
last_update2018-01-27 23:00:18
depth1
children2
last_payout2018-02-03 23:00:18
cashout_time1969-12-31 23:59:59
total_payout_value1.264 HBD
curator_payout_value0.418 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length347
author_reputation75,981,011,753,578
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,852,994
net_rshares203,233,337,244
author_curate_reward""
vote details (1)
@gabox ·
Thank you for your great support @favcau, I know that for those of us who handle the language in a complete way this can be very simple, however I want to direct this consensus from the most basic to the most advanced, as even these tutorials their difficulty Increasing anger, likewise I will do everything possible to provide more content in them.
You are absolutely right about the comments that have more than one line, once again thanks for keeping me in mind.
properties (22)
authorgabox
permlinkre-favcau-re-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180128t073425944z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["favcau"],"app":"steemit/0.1"}
created2018-01-28 07:06:21
last_update2018-01-28 07:06:21
depth2
children0
last_payout2018-02-04 07:06:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length465
author_reputation309,708,176,468,307
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,933,870
net_rshares0
@utopian.tip ·
Hey @favcau, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
properties (22)
authorutopian.tip
permlinkre-re-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180127t230005099z-20180128t013852
categoryutopian-io
json_metadata""
created2018-01-28 01:39:00
last_update2018-01-28 01:39:00
depth2
children0
last_payout2018-02-04 01:39:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length156
author_reputation238,310,597,885
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,879,794
net_rshares0
@graceleon ·
full interesante no dejes de hacerlo
properties (22)
authorgraceleon
permlinkre-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180129t031743485z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-29 02:47:54
last_update2018-01-29 02:47:54
depth1
children0
last_payout2018-02-05 02:47:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length36
author_reputation30,295,236,936,547
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id33,165,188
net_rshares0
@untitledvzla ·
Muy bueno tu post. que te parece si nos unimos para hacer mas tutoriales de python pero enfocados en la libreria Pygame te puedo ayudar en eso saludos
properties (22)
authoruntitledvzla
permlinkre-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180128t235614007z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-28 23:23:30
last_update2018-01-28 23:23:30
depth1
children0
last_payout2018-02-04 23:23:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length150
author_reputation81,413,990,309
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id33,127,365
net_rshares0
@utopian-io ·
### Hey @gabox I am @utopian-io. I have just upvoted you!
#### Achievements
- Seems like you contribute quite often. AMAZING!
#### Suggestions
- Contribute more often to get higher and higher rewards. I wish to see you often!
- Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!
#### Get Noticed!
- Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!
#### Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
properties (22)
authorutopian-io
permlinkre-gabox-tutorial-2-python-comentarios-y-operadores-aritmeticos-20180128t191757980z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-28 19:17:57
last_update2018-01-28 19:17:57
depth1
children0
last_payout2018-02-04 19:17:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,425
author_reputation152,955,367,999,756
root_title"Tutorial #2 Python: Comentarios y Operadores Aritméticos"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id33,080,301
net_rshares0