# Author:
# Date: 4/18/25
# Exam 1, Problem 2 (10 out of 20 points)

""" This program converts units of weight between metric (kilograms and grams)
and imperial (pounds and ounces) units.

The program takes two command line arguments:
- The first argument is a floating-point or integer weight
- The second is a unit, either "kg" (kilograms) or "lb" (pounds)

Based on the unit, the program converts the given weight into the other
measurement system. The output display s a whole number of the major unit -
kg or lb - and a decimal number of a minor unit - g (grams) or oz (ounces).

Here are some helpful conversion constants for your use:
- 1 pound = 0.45359237 kilograms
- 1 pound = 16 ounces
- 1 kilogram = 1000 grams

For the minor unit value (grams or ounces), the output is considered correct if
it is within 1% of the expected output.

Here are some sample outputs:
>>> %Run p2.py 1 kg
2 lb 3.273919999999997 oz

>>> %Run p2.py 0.45359237 kg
1 lb 0.0 oz

>>> %Run p2.py 1 lb
0 kg 453.59237 g

>>> %Run p2.py 135 lb
61 kg 234.96994999999998 g

The tests check the following requirements; I recommend meeting them
in this order and testing as you go.
* For kg-to-lb conversion:
  - Output is in the correct format (number unit number unit)
  - Major unit number is the correct integer
  - Minor unit number is correct (less than 1% off the expected number)
* Each of the above, but for lb-to-kg conversion.

Write your code below:
"""

import sys

input_weight = float(sys.argv[1])
input_unit = sys.argv[2]

if input_unit == "kg":
    pounds = input_weight / 0.45359237
    int_pounds = int(pounds)
    ounces = (pounds - int_pounds) * 16
    print(int_pounds, "lb", ounces, "oz")
    