snipt

Ctrl+h for KB shortcuts

Python

return hexadecimal representation of integer

def dec2hex(n):
    return "%X" % n
https://snipt.net/embed/6ae348bffd5515cb0e73e3f94e5b6db5/
/raw/6ae348bffd5515cb0e73e3f94e5b6db5/
6ae348bffd5515cb0e73e3f94e5b6db5
python
Python
2
2019-08-20T21:28:48
True
False
False
/api/public/snipt/28373/
return-hexadecimal-representation-of-integer
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">def</span> <span class="nf">dec2hex</span><span class="p">(</span><span class="n">n</span><span class="p">):</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="s2">&quot;</span><span class="si">%X</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">n</span> </span></pre></div> </td></tr></table>
base, hex, python