def test_minutes_to_years(self): self.assertEqual(1, minutes_to_years(525600))
# parse command line arguments parser = argparse.ArgumentParser() parser.add_argument('value', type = float, help = 'A number to be converted') args = parser.parse_args() # perform conversions # km to miles to_miles = kilometers_to_miles(args.value) print('{0} kilometers is {1} miles'.format(args.value, to_miles)) # miles to km to_km = miles_to_kilometers(args.value) print('{0} miles is {1} kilometers'.format(args.value, to_km)) # years to minutes to_minutes = years_to_minutes(args.value) print('{0} years is {1} minutes'.format(args.value, to_minutes)) # minutes to years to_years = minutes_to_years(args.value) print('{0} minutes is {1} years'.format(args.value, to_years)) # monkeys that x bananas will feed monkeys_fed = bananas_to_monkeys(args.value) print('You have only grown {0} bananas. That will only feed {1} monkeys. Not enough, grow more!'.format(args.value, monkeys_fed)) # lbs of poo that is produced per monkey poo_produced = monkeys_to_ammunition(args.value) print('With {0} fed monkeys we will be able to produce {1}lbs of poo. Mwahahahahaha, soon the world will be within our grasp'.format(args.value, poo_produced))
# Command line script to convert a given number from one unit, to another. # Assigns multiple units to given number and converts them all. import argparse from src.convert import kilometer_to_miles, miles_to_kilometer, years_to_minutes, minutes_to_years # Command line parse options parser = argparse.ArgumentParser() parser.add_argument('value', type=float, help="Enter the number to be converted.") args = parser.parse_args() # Unit conversions below here #km to miles km_2_mi = kilometers_to_miles(args.value) print("{0} kilometers is {1} miles.".format(args.value, km_2_miles)) # Miles to km mi_2_km = miles_to_kilometers(args.value) print("{0} miles is {1} kilometers.".format(args.value, mi_2_km)) # Years to minutes yrs_2_min = years_to_minutes(args.value) print("{0} years is {1} minutes.".format(args.value, yrs_2_min)) # Minutes to years min_2_yrs = minutes_to_years(args.value) print("{0} minutes is {1} years.".format(args.value, min_2_yrs))