NumPy Quiz

Welcome to The Coding College, where learning meets fun! This NumPy Quiz is designed to help you evaluate your understanding of the essential concepts of NumPy, the popular Python library for numerical computing. Whether you’re a beginner or a seasoned developer, this quiz will test your skills and deepen your knowledge.

About the Quiz

This quiz covers key topics in NumPy, including array creation, manipulation, mathematical functions, and advanced operations. Each question comes with multiple-choice options and answers to help you learn and improve.

NumPy Quiz Questions

Question 1: Array Creation

Which of the following functions is used to create an array in NumPy?

  • A. array()
  • B. create_array()
  • C. make_array()
  • D. new_array()

Question 2: Array Dimensions

What is the term used to describe the number of dimensions of a NumPy array?

  • A. Rank
  • B. Shape
  • C. Size
  • D. Dimension

Question 3: Array Indexing

If arr = np.array([10, 20, 30, 40, 50]), what will arr[3] return?

  • A. 10
  • B. 20
  • C. 30
  • D. 40

Question 4: Array Slicing

What does arr[1:4] return if arr = np.array([0, 1, 2, 3, 4, 5])?

  • A. [0, 1, 2]
  • B. [1, 2, 3]
  • C. [2, 3, 4]
  • D. [3, 4, 5]

Question 5: Unique Elements

Which function is used to find unique elements in a NumPy array?

  • A. np.distinct()
  • B. np.unique()
  • C. np.elements()
  • D. np.find_unique()

Question 6: Array Shape

What does the shape attribute of a NumPy array return?

  • A. Total number of elements
  • B. Dimensions of the array
  • C. Size of the largest dimension
  • D. Data type of elements

Question 7: Mathematical Functions

Which of the following functions can be used to calculate the square root of each element in a NumPy array?

  • A. np.sqrt()
  • B. np.pow()
  • C. np.log()
  • D. np.exp()

Question 8: Broadcasting

What is broadcasting in NumPy?

  • A. Copying an array multiple times
  • B. Performing operations on arrays of different shapes
  • C. Broadcasting a message to all array elements
  • D. Converting arrays to the same shape

Question 9: Random Numbers

Which function generates a random array in NumPy?

  • A. np.random.rand()
  • B. np.random.generate()
  • C. np.random.array()
  • D. np.random.create()

Question 10: File I/O

Which function is used to save a NumPy array to a file?

  • A. np.save()
  • B. np.write()
  • C. np.export()
  • D. np.file()

Scoring

  • 0–4 Correct: Beginner – You’re just getting started. Keep practicing!
  • 5–7 Correct: Intermediate – You’ve got a good grasp of NumPy basics.
  • 8–10 Correct: Advanced – You’re a NumPy expert!

Why NumPy is Essential

NumPy is a foundational library for numerical computations in Python. It’s widely used in fields like data science, machine learning, and scientific computing. Mastering NumPy is a key step in becoming a proficient Python developer.

For more NumPy tutorials, quizzes, and coding tips, visit The Coding College, your go-to resource for learning programming

Leave a Comment