Question: PYTHON or c++ def main(): distx = float (input(Enter a number:)) unitx = str (input(Enter source unit:)) disty = float(input(Enter another number:)) unity = input(Enter
PYTHON or c++
def main():
distx = float (input("Enter a number:"))
unitx = str (input("Enter source unit:"))
disty = float(input("Enter another number:"))
unity = input("Enter conversion unit: ")
angleA = float(input ("Enter a angle number:"))
angleAUnit = str(input ("Enter the angle unit:"))
contain a function called convert() that takes a quantity, and a unit 'source' parameters, and destination unit parameter. For example: (1, "parsec", "kilometer") returns 30860000000000 For example: (45, "degrees", "radian") returns .7853985 convert() will return a quantity that you have calculated . Note, you should not assume the units are "set". You should create an array (or dictionary) for all units. Poor programming will produce a convert() function that is full of conditional statements instead of one simple math calculation. Conversion between units is as follows: parsec to lightyear (1 parsec = 3.26 lightyears) lightyear to kilometer (1 lightyear = 9.461 x 10^12 kilometers) xlarn to parsec (1 xlarn = 6.3762 parsec) degree to radian (1 degree = 0.0174533 radian) radian to xarnian (1 radian = 100 xarnian) xarnian to degree (1 xarnian = .572958 degree)
Calculate the distance using the law of cosine.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
