Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

NumPy Arrays and Dat | Master Data Science with Python lesso | BraveProgrammer
  1. Courses
  2. /
  3. Master Data Science with Python

Lesson 7 of 60

·python

NumPy Arrays and Data Types

15 minutes

Course progress12%

NumPy Arrays and Data Types

NumPy arrays (ndarray) are homogeneous – every element shares the same data type (dtype).

Creating arrays of different dims

import numpy as np

# 1‑D array (vector)
vec = np.arange(5)          # [0 1 2 3 4]

# 2‑D array (matrix)
mat = np.arange().reshape(,)
(mat)



tensor = np.arange().reshape(,,)
(tensor.shape)
12
3
4
print
# 3‑D array (tensor)
# shape: (2, 3, 4)
24
2
3
4
print

Specifying data types

float_arr = np.array([1, 2, 3], dtype=np.float64)
int_arr = np.array([1.2, 2.5, 3.7], dtype=np.int32)  # truncates

Inspecting dtype

print(float_arr.dtype)   # float64
print(int_arr.dtype)     # int32

Common dtypes

  • np.int8, np.int16, np.int32, np.int64
  • np.uint8, np.uint16, …
  • np.float16, np.float32, np.float64
  • np.bool_

Info

Use the smallest dtype that captures your data to save memory.
Make it stickPractice what you've learned1 quiz · 4 practical tests · Optional activities from Master Data Science with PythonBrowse activities
Previous lessonIntroduction to NumPyContinue to lesson 8Indexing, Slicing, and Iterating in NumPyBack to Master Data Science with Python curriculum