Introduction and Lesson Overview

Welcome! In today's lesson, we'll learn how to use functions with NumPy arrays, a crucial concept for managing large amounts of data. This ability facilitates efficient data processing — a teacher calculating class averages or a business analyst summarising company sales illustrates the practical use of these skills. Are you ready? Let's get started!

Arithmetic Operations with NumPy Arrays

Two arrays of the same shape can undergo basic arithmetic operations. The operations are performed element-wise, meaning they're applied to each pair of corresponding elements. Suppose we have two grade arrays of students from two subjects. By adding these arrays, we can calculate the total grades:

The two arrays are added element-wise in this code to calculate the total grades.

Introduction to Universal Functions (ufuncs)

NumPy's Universal Functions (also called ufuncs) perform element-wise operations on arrays, including mathematical functions like sin, cos, log, and sqrt. Let's look at a use case:

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal