Skip to Content

CL-9-Session-4 Numpy.pptx

Numpy

"With NumPy, we move from slow Python loops to fast vectorized operations—science at speed."

                                                           — Jake VanderPlas
(Open Source Developer- Google, Seattle WA)


Introduction

NumPy (Numerical Python) is a fundamental package for scientific computing in Python. It provides support for large, multi-dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays efficiently

Learning Objectives

  • In this session, students will be able to understand and apply the concepts of array and numpy using python programming. 
  • They will learn how to use array and numpy library in their code.

What is numpy?

  • NumPy is a Python library used for working with arrays.
  • It also has functions for working in domain of linear algebra, Fourier transform, and matrices.
  • NumPy was created in 2005 by Travis Oliphant. It is an open source project and you can use it freely.
  • NumPy stands for Numerical Python.

Array Indexing

  • Array indexing is the same as accessing an array element.
  • You can access an array element by referring to its index number.
  • The indexes in NumPy arrays start with 0, meaning that the first element has index 0, and the second has index 1 etc.

Array Slicing 

  • Slicing in python means taking elements from one given index to another given index.
  • We pass slice instead of index like this: [start:end].
  • We can also define the step, like this: [start:end:step].
  • If we don't pass start its considered 0
  • If we don't pass end its considered length of array in that dimension
  • If we don't pass step it's considered 1

 Requirements:

  • Computers or tablets with python installed or internet access for Scratch online.
  • Basic python knowledge (numpy lib, array).
  • Sample projects and visual aids to demonstrate array.
  • Teacher guidance with step-by-step instructions and hands-on activities.

Code 

Activity 1 : Get first element from following array 

Output

Activity 2: Slice elements from 1 to index 5 from the following array-

Output

Learning Outcome-

  • Students will understand what is Array indexing and Array slicing.
  • Students will learn Array indexing & Its uses.
  • Students will learn Array slicing and its operations.

 
0 0

There are no comments for now.

to be the first to leave a comment.