Skip to content

Commit

Permalink
Created a snippet to convert centimeters to inches
Browse files Browse the repository at this point in the history
  • Loading branch information
AnirudhRevanur committed Sep 21, 2023
1 parent dd693b2 commit 919c08e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions snippets/python/s/cm-to-inch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Centimeter to Inch converter
type: snippet
language: python
tags: [math]
cover: blue-computer
dateModified: 2023-09-21T09:48:37+05:30
---

Converts Centimeters to Inches

- Follows the conversion formula `in = cm / 2.54`

```py
def centimeters_to_inches(centimeters):
inches = centimeters / 2.54
return f"{inches:.2f}"
```

```py
centimeters_to_inches(15) # 5.91

0 comments on commit 919c08e

Please sign in to comment.