Created
August 4, 2021 00:26
-
-
Save oiojin831/15868a09b6076f536c64e2c8e15faec4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cm_to_inch(cm): | |
return cm / 2.54 | |
def inch_to_cm(inch): | |
return inch * 2.54 | |
def unit_converter(num, unit): | |
if unit == "inch": | |
new_cm = inch_to_cm(num) | |
return f"{new_cm} cm" | |
elif unit == "cm": | |
new_inch = cm_to_inch(num) | |
return f"{new_inch} inch" | |
print(unit_converter(10, "inch")) | |
print(unit_converter(25.4, "cm")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment