Question: :Python Program: Or C++ contain a function called convert() that takes a quantity, and a unit 'source' parameters, and destination unit parameter. For example: (1,
:Python Program: Or C++
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)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
