{"id":32675,"date":"2021-04-28T11:30:00","date_gmt":"2021-04-28T09:30:00","guid":{"rendered":"https:\/\/eiposgrados.com\/?p=32675"},"modified":"2021-04-28T11:52:35","modified_gmt":"2021-04-28T09:52:35","slug":"how-to-calculate-weight-on-mars","status":"publish","type":"post","link":"https:\/\/eiposgrados.com\/eng\/python-blog\/how-to-calculate-weight-on-mars\/","title":{"rendered":"How much do you weigh on Mars?"},"content":{"rendered":"<p>In previous posts we have seen the <a href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/python-basic-operator-types\/\" class=\"rank-math-link\">logical operators<\/a> of Python, the <a href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/python-reserved-words\/\" class=\"rank-math-link\">keywords<\/a> and the <a href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/phyton-predefined-functions\/\" class=\"rank-math-link\">predefined functions<\/a>. Well, today we are going to put into practice what we have learned with a curious exercise to <strong>calculate what we would weigh on Mars.<\/strong> <\/p>\n\n\n\n<p>The steps we must follow are explained to us <a href=\"https:\/\/es.linkedin.com\/in\/maria-jose-pe%C3%B1a-carrilero\" class=\"rank-math-link\" target=\"_blank\" rel=\"noopener\">Maria Jose Pena<\/a>, Director of<strong> <a href=\"https:\/\/eiposgrados.com\/eng\/master-in-python\/\" class=\"rank-math-link\">Master of Advanced Programming in Python for Big Data, Hacking and Machine Learning<\/a> <\/strong>in <a href=\"https:\/\/eiposgrados.com\/eng\/\" class=\"rank-math-link\">EIP <\/a>to be able to calculate our weight on Mars. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">We start with this code<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"158\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.56.19-1024x158.png\" alt=\"\" class=\"wp-image-32676\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.56.19-1024x158.png 1024w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.56.19-300x46.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.56.19-768x119.png 768w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.56.19.png 1398w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Where <strong>weightonearth<\/strong> It is a float type variable that collects by keyboard the weight we have on earth.<\/p>\n\n\n\n<p><strong>weightOnMars <\/strong>It is the variable where we convert the weight of the Earth into the weight we would have on Mars with a simple formula that we have located in the wonderful Google.<\/p>\n\n\n\n<p>And finally we print on the screen <strong>weightOnMars<\/strong> converting it into text with the <a class=\"rank-math-link\" href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/phyton-predefined-functions\/\">predefined function<\/a> \u201c<em>str<\/em>\u201d and chaining it with a little message.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Result we get<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/AiJjaPxSBl0Fr4Ny1Rp7hs3PWnEZm5E22ve7yBdRGUxCdnd2pP_rbotbNFCNFPvqk2DWRa8d-_tldRKUyFWnIzmpmamXr5LVulcIDugtzrLb8jwpYZhNJpetFgoeSnVOme_zN0ylnoHX25S_3A\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>But we&#039;re going to give it a spin.<strong> Let&#039;s put a condition <\/strong>about the weight so that it sends us one message or another depending on the value of the variable <strong>weightOnMars:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"390\" src=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.57.06-1024x390.png\" alt=\"how to calculate weight on mars\" class=\"wp-image-32677\" title=\"\" srcset=\"https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.57.06-1024x390.png 1024w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.57.06-300x114.png 300w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.57.06-768x293.png 768w, https:\/\/eiposgrados.com\/wp-content\/uploads\/2021\/04\/Captura-de-pantalla-2021-04-28-a-las-10.57.06.png 1396w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In the first condition (if), we say that if <strong>weightOnMars<\/strong> is greater than or equal to 35, print the message.<\/p>\n\n\n\n<p>If the first condition is not met, go to the next one (elif) where if <strong>weightOnMars<\/strong>&nbsp; is greater than or equal to 25 and less than 35, print the message, here we are already using the and operator that we saw in the previous post, <a href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/python-basic-operator-types\/\">logical operators<\/a> and in the <a href=\"https:\/\/eiposgrados.com\/eng\/python-blog\/python-reserved-words\/\">keywords<\/a>.<\/p>\n\n\n\n<p>Finally, if none of the above is true, it means that pesoEnMarte is less than 25 and therefore the last message is printed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Examples of the above<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/Jz1pbDhDuGmgOP50A-3JrZMQ3H1YWNRO9Weub4UNTMgBgEQ94iYl4NzMgMwYvGSwkai3DBi8Z5QgRUuWIpH0J4Vv9GQGu1c72OHvsUe39WYRdPd6AjZLrvJyqpqLVn48TP36A9RkuKvz5-cVyw\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/lXoBueZ1Fhdo51Pd9-nPsZdMGkU3EqsQdacoH7uscuVH6BjrKCaUsJ00yfSy0A3MgmIKWainV5tYvhrCYhvyTcdWwwhffGIvhzfqtyH2UuGDCTLubWEq8TWcXtPAJ0V9R4qbg3stXa5LCkRxhg\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/5WbVbaxn4WH1c-tcMy73Sl2p5ZZFWuAH0zQMvId9qKrFx2m0G4h8j0swHM08IXI1FOh9BmxejS-JVRFTV1OASnKcG--jPR6vNhVe0MnEwhKj1NgQjkvfqk-zjBzVL5Nf0UbRhzOtIGKPTrMmbA\" alt=\"\" title=\"\"><\/figure>\n\n\n\n<p>Did you find it interesting how to calculate your weight on Mars? We hope you try to calculate it. You can tell us in comments. We read you!<\/p>","protected":false},"excerpt":{"rendered":"<p>How to calculate weight on Mars? Mar\u00eda Jos\u00e9 Pe\u00f1a, Director of the Master in Programming Advances in Python, gives us the steps to calculate it. <\/p>","protected":false},"author":51,"featured_media":32678,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[407],"tags":[],"class_list":["post-32675","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-python"],"acf":[],"_links":{"self":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/32675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/users\/51"}],"replies":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/comments?post=32675"}],"version-history":[{"count":0,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/32675\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media\/32678"}],"wp:attachment":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media?parent=32675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/categories?post=32675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/tags?post=32675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}