From dd693b28b0291041b1493f1ab087a3c46aa7d724 Mon Sep 17 00:00:00 2001 From: ClayTsunami Date: Thu, 21 Sep 2023 21:54:39 +0530 Subject: [PATCH] Created a snippet to convert inches to centimeters --- snippets/python/s/inch-to-cm.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 snippets/python/s/inch-to-cm.md diff --git a/snippets/python/s/inch-to-cm.md b/snippets/python/s/inch-to-cm.md new file mode 100644 index 00000000000..3de9b224ca8 --- /dev/null +++ b/snippets/python/s/inch-to-cm.md @@ -0,0 +1,22 @@ +--- +title: Inch to Centimeter converter +type: snippet +language: python +tags: [math] +cover: dark-city +dateModified: 2023-09-21T09:38:54+05:30 +--- + +Converts Inches to Centimeters + +- Follows the conversion formula `cm = in * 2.54`. + +```py +def inches_to_centimeters(inches): + centimeters = inches * 2.54 + return f"{centimeters:.2f}" +``` + +```py +inches_to_centimeters(15) # 38.10 +``` \ No newline at end of file