Created
October 6, 2020 00:52
-
-
Save jacobeturpin/c53ef60eeb4e3bc84818d1f5a036a74e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
""" | |
Simple Click example | |
""" | |
import click | |
@click.command() | |
@click.option('--km', default=1, help='Number of kilometers') | |
@click.option('--dec', default=2, help='Number of digits after decimal') | |
def km_to_mi(km, dec): | |
# conversion factor | |
conv_fac = 0.621371 | |
# calculate miles | |
miles = round(km * conv_fac, dec) | |
print('{} kilometers is equal to {} miles'.format(km, miles)) | |
if __name__ == '__main__': | |
km_to_mi() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment