Question

Write in python The main goal of this file will be to produce a 2D numpy array that could serve a...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:

5. 5.5 6 6.5 11. 15.5 16 9.5 10 10.5 11.5 12 12.5 13. 17.5 14.5 15 19. 23.5 24 16.5 17 21. 25.5 26 13.514. 18.5 23. 27.528. 1

Add a comment
Know the answer?
Add Answer to:
Write in python The main goal of this file will be to produce a 2D numpy array that could serve a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT