Merge pull request #316 from pracheejaviya1/conversion

Added decimal to hex conversion
This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-09 09:45:59 +03:00
committed by GitHub

18
snippets/to_hex.md Normal file
View File

@ -0,0 +1,18 @@
---
title: to_hex
tags: math,beginner
---
Returns the hexadecimal representation of the given number.
- Use `hex()` to convert a given decimal number into its hexadecimal equivalent.
```py
def to_hex(dec):
return hex(dec)
```
```py
to_hex(41) # 0x29
to_hex(332) # 0x14c
```