{"id":594,"date":"2009-10-19T00:20:37","date_gmt":"2009-10-19T03:20:37","guid":{"rendered":"http:\/\/wordpress.matbra.com\/?p=594"},"modified":"2010-08-03T18:10:17","modified_gmt":"2010-08-03T21:10:17","slug":"mudanca-de-base-numerica-com-python","status":"publish","type":"post","link":"https:\/\/wordpress.matbra.com\/en\/2009\/10\/19\/mudanca-de-base-numerica-com-python\/","title":{"rendered":"Change numeric base using Python"},"content":{"rendered":"<p>Hello,\n\nHow to change the numeric base of a number? This is a implementation in Python. \n\n[code lang=\"python\"]\ndef convert(decimal,newBase,str,letters):\n\tif decimal >= newBase:<br \/>\n\t\tx = decimal % newBase<br \/>\n\t\ty = decimal \/ newBase<br \/>\n\t\tstr = letters[x] + str<br \/>\n\t\tif y < newBase:\n\t\t\tstr = letters[y] + str\n\t\treturn convert(y,newBase,str,letters)\t\n\telse:\n\t\tif len(str) == 0:\n\t\t\tstr = letters[decimal] + str\n\t\treturn str\nlet = \"0123456789ABCDEF\"\nprint convert(17,16,\"\",let)\n[\/code]\n\nThe variable let means what values used in the base. For an example if you want binary you should replace with 01. \n\nMatheus\n<\/p>","protected":false},"excerpt":{"rendered":"<p>Hello, How to change the numeric base of a number? This is a implementation in Python. [code lang=&#8221;python&#8221;] def convert(decimal,newBase,str,letters): if decimal >= newBase: x&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/wordpress.matbra.com\/en\/2009\/10\/19\/mudanca-de-base-numerica-com-python\/\">Continue reading<span class=\"screen-reader-text\">Change numeric base using Python<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7,156],"tags":[],"class_list":["post-594","post","type-post","status-publish","format-standard","hentry","category-aprendendo","category-python","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/psjGE-9A","_links":{"self":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/comments?post=594"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/594\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/media?parent=594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/categories?post=594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/tags?post=594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}