write in python
The main goal of this file will be to produce a 2D numpy array that could serve as a visual look-up table for the following length units: kilometers, miles, and nautical miles. The variable name for this array should be ltable (standing for length table).
The look-up values will be dictated by values for kilometers that should go from 0 to 30 in half-kilometer increments (0, 0.5, 1, 1.5, ..., 28.5, 29, 29.5, 30). The kilometer (km) values will go in the first column. The second column will be lengths in units of miles (mi). Use a conversion factor of exactly 1.607 km/mi. The third column will be lengths in nautical miles (nm) and use a conversion factor of exactly 0.54 nm/km.
Python Code:
"""
Python program that prints the length units:
kilometers, miles, and nautical miles
"""
import numpy as np
# Creating an array of kilometers
km = [i for i in np.arange(0,30.5,0.5)];
km = np.array(km);
# Creating an array of miles
miles = [i*1.607 for i in np.arange(0,30,0.5)];
miles = np.array(miles);
# Creating an array of nautical miles
nm = [i*0.54 for i in np.arange(0,30,0.5)];
nm = np.array(nm);
# Creating a table
ltable = np.concatenate((km, miles, nm), axis=0);
print(ltable)
Sample Run:
Write in python The main goal of this file will be to produce a 2D numpy array that could serve a...