Getting the Hex values

  • Comments posted to this topic are about the item Getting the Hex values

  • The correct answer (according to me :D) isn't available in the list of answers.  The correct answer would be to do it in T-SQL. 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Yesterday I gave up QotD after I couldn't decide which way was best. I wrote DecToHexa (n) function, which may be the answer # 1.

    According to docs Built-in Functions this may be the answer # 3.

    According to Type Conversion in Python, this may be the answer # 4.

    But in my life sport sometimes taught me losing too. I swear I haven't looked for the right answer yet, and now I'm boldly answering # 4. Hmm... I got it wrong. Anyway thanks Steve for this funy question. Jeff was right ...

    # Function definition is here
    def DecToHexa(n):
    result = str(hex(n))
    return result;
    # Now you can call DecToHexa function
    n = 254
    result = DecToHexa(n);
    print('Hexadecimal value of '+ str(n) +' is: ' + result);

    Result pane:
    $python main.py
    Hexadecimal value of 254 is: 0xfe
  • Nice one, thanks Steve

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply