Files
30-seconds-of-code/snippets/to_hex.md
Isabelle Viktoria Maciohsek cbc78ee450 Bake dates into snippets
2021-06-13 19:38:10 +03:00

21 lines
356 B
Markdown

---
title: to_hex
tags: math,beginner
firstSeen: 2020-10-09T09:45:47+03:00
lastUpdated: 2020-10-09T09:45:47+03:00
---
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
```