MBOSE Class XI Informatics Practices · Chapter 6
Introduction to NumPy
Opening soonNumPy gives Python the array: a table of numbers of one type, made here from a list, on which one statement works on every element.
11 lessons · 65 practice questions
What this chapter covers
- Introduction to NumPy
- Creation of NumPy arrays from a list
Key terms
- NumPy
Numerical Python, a package for arrays
- ndarray
The NumPy array class
- Array
Elements of one type stored side by side
- Axis
A dimension of an array (0 = rows, 1 = columns)
shapeTuple of sizes of the dimensions
sizeTotal number of elements
dtypeData type of the elements
- Nested list
A list whose items are lists
- Element-wise
Applied to each element in turn
Important questions with answers
10 of the 65 questions on this chapter, solved.
Question 1 · Multiple choice · 1 mark
NumPy stands for
- (a) Numeric Pandas
- (b) Number Pointer
- (c) Numerical Python
- (d) New Python
Answer: (c) Numerical Python
NumPy is Numerical Python.
Question 2 · Multiple choice · 1 mark
For a list
lst, the statementlst * 2- (a) repeats the list
- (b) doubles each element
- (c) gives an error
- (d) deletes the list
Answer: (a) repeats the list
A list is repeated, not multiplied.
Question 3 · Multiple choice · 1 mark
A list of numbers gives a
- (a) 1-D array
- (b) 2-D array
- (c) 3-D array
- (d) 0-D array only
Answer: (a) 1-D array
A flat list is one-dimensional.
Question 4 · Multiple choice · 1 mark
The dtype of np.array([1, 'a']) is
- (a) string
- (b) int
- (c) float
- (d) bool
Answer: (a) string
Text forces text.
Question 5 · Assertion and reason · 1 mark
Assertion (A): All elements of a NumPy array have the same data type.
Reason (R): NumPy converts mixed values in a list to one common type.
- (a) Both A and R are true, and R is the correct explanation of A.
- (b) Both A and R are true, but R is not the correct explanation of A.
- (c) A is true, but R is false.
- (d) A is false, but R is true.
Answer: (a) Both A and R are true, and R is the correct explanation of A.
R explains A.
Question 6 · Short answer · 1 mark
Expand NumPy.
Answer
Numerical Python.
Question 7 · Short answer · 2 marks
What is an array? Name two of its characteristics.
Answer
An array stores many values under one name. All elements have the same data type, and they are stored side by side in memory.
Question 8 · Short answer · 3 marks
Write a program to create a 2-D array from the list
[[1, 2, 3], [4, 5, 6]]and print its shape and size.import numpy as np a = np.array([[1, 2, 3], [4, 5, 6]]) print(a.shape, a.size)Output:
(2, 3) 6Answer
The shape is
(2, 3)and the size is 6. (1 for the array, 1 for each attribute)Question 9 · Long answer · 5 marks
What is NumPy? Explain the characteristics of an array and the differences between a list and an array.
Answer
Sections 1.1.
Question 10 · Long answer · 5 marks
Explain how arrays are created from lists, including nested lists and lists of mixed types, with examples.
Answer
Section 1.2.
Study the whole chapter
11 step-by-step lessons, all 65 practice questions with hints, flashcards and mock tests for MBOSE Class XI Informatics Practices.