Update and rename dec_to_hex.md to to_hex.md
This commit is contained in:
committed by
GitHub
parent
bf1afde0f7
commit
8f0718916d
@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
title: decimal to hexadecimal
|
|
||||||
tags: conversion, beginner
|
|
||||||
---
|
|
||||||
|
|
||||||
Returns hexadeciaml equivalent of decimal
|
|
||||||
|
|
||||||
- Use `hex()` function for conversion
|
|
||||||
|
|
||||||
```py
|
|
||||||
def conversion(dec):
|
|
||||||
return hex(dec)
|
|
||||||
```
|
|
||||||
|
|
||||||
```py
|
|
||||||
conversion(41) #29
|
|
||||||
conversion(332) #14C
|
|
||||||
```
|
|
||||||
18
snippets/to_hex.md
Normal file
18
snippets/to_hex.md
Normal 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
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user