Skip to content

Change numeric base using Python

Hello,

How to change the numeric base of a number? This is a implementation in Python.

[code lang=”python”]
def convert(decimal,newBase,str,letters):
if decimal >= newBase:
x = decimal % newBase
y = decimal / newBase
str = letters[x] + str
if y < newBase: str = letters[y] + str return convert(y,newBase,str,letters) else: if len(str) == 0: str = letters[decimal] + str return str let = "0123456789ABCDEF" print convert(17,16,"",let) [/code] The variable let means what values used in the base. For an example if you want binary you should replace with 01. Matheus

Published inAprendendopython

736 Comments

  1. slots no deposit bonus uk, casino fun usa and united kingdom
    online pokies 2021, or top 10 betterdice casino reviews;
    Jayson,
    canada

  2. south united states casinos, casinos in ontario
    canada and casino gananoque ontario canada, or
    online casino australia best numbers to choose in roulette, Tyree,
    payout

  3. $1 minimum deposit mobile casino canada, online bingo slots uk and free no deposit australia casino, or australian online
    gambling legislation

    my web-site :: how to win in russian roulette – Chante,

  4. las vegas usa casino dice craps table [Modesta] reviews,
    gousaos quest free spins no deposit and real money online casinos united
    states, or 100 slots bonus usa

  5. pokie machine laws canada, online trusted my games casino (Vanessa) usa and poker stars uk offers, or best online casino sites
    for real money canada

  6. united kingdom gambling commission, money poker online usa and united
    kingdom pokies no deposit bonus, or is online poker coming back
    to united states

    My website: mobile phone casino deposits (Mario)

  7. gold coast casino australia, new zealandn roulette table and united kingdom online
    betreels casino review (Rogelio) no
    deposit bonus codes 2021, or uk gambling license conditions

Leave a Reply

Your email address will not be published. Required fields are marked *