Nest all content into snippets
This commit is contained in:
22
snippets/python/s/to-hex.md
Normal file
22
snippets/python/s/to-hex.md
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
title: Number to hex
|
||||
type: snippet
|
||||
language: python
|
||||
tags: [math]
|
||||
cover: green-plant
|
||||
dateModified: 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
|
||||
```
|
||||
Reference in New Issue
Block a user