MulaiMulai sekarang secara gratis

A range array

np.arange() has especially useful applications in graphing. Your task is to create a scatter plot with the values from doubling_array on the y-axis.

doubling_array = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]

Recall that a scatter plot can be created using the following code:

plt.scatter(x_values, y_values)
plt.show()

With doubling_array on the y-axis, you now need values for the x-axis, which you can create with np.arange()!

numpy is loaded for you as np, and matplotlib.pyplot is imported as plt.

Latihan ini adalah bagian dari kursus

Introduction to NumPy

Lihat Kursus

Petunjuk latihan

  • Using np.arange(), create a 1D array called one_to_ten which holds all integers from one to ten (inclusive).
  • Create a scatterplot with doubling_array as the y values and one_to_ten as the x values.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Create an array of integers from one to ten
one_to_ten = ____

# Create your scatterplot
____
plt.show()
Edit dan Jalankan Kode