Entrance Announcement
MICTE
2080
2080 Magh 07
Please contact us
Editing
User:Niraj/Teaching-16
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
'''Teaching lesson plan 16 Subject: Python programming''' '''Date: 1 Feb 2024''' '''Time: 60 minutes''' '''Period: 3rd''' '''Teaching Item: Indexing Arrays in NumPy''' '''Class: Bachelor''' '''Objective:''' Students will learn about indexing and slicing arrays in NumPy, understand the syntax for accessing elements and subarrays, and apply indexing techniques to manipulate array data effectively. Prerequisites: Basic understanding of Python programming language, including variables, data types, and basic NumPy array creation. '''Materials Needed:''' * Python interpreter with NumPy installed or IDE * Projector '''1. Introduction to Array Indexing (10 mins)''' * Recap the concept of arrays in NumPy: ** Arrays are the primary data structure in NumPy, representing multi-dimensional collections of elements. ** Arrays can be indexed and sliced to access individual elements or subarrays. * Introduce the importance of indexing for accessing and manipulating array data. '''2. Indexing and Slicing Basics (15 mins)''' * Discuss basic indexing and slicing syntax in NumPy: ** Indexing: Accessing individual elements of an array using square brackets <code>[]</code>. ** Slicing: Extracting subarrays using the colon <code>:</code> operator to specify start, stop, and step values. * Demonstrate how to use indexing and slicing to access elements and subarrays with examples. '''3. Indexing Multi-dimensional Arrays (15 mins)''' * Explore indexing and slicing in multi-dimensional arrays: ** Discuss the use of comma-separated indices to access elements of multi-dimensional arrays. ** Explain the concept of array axes and how they relate to indexing. ** Show examples of indexing multi-dimensional arrays along different axes. * Demonstrate how to use indexing to access rows, columns, and specific elements of multi-dimensional arrays. '''4. Boolean Indexing (10 mins)''' * Introduce boolean indexing as a powerful technique for array manipulation: ** Boolean arrays can be used to filter and select elements based on specified conditions. ** Discuss how to create boolean arrays using comparison operators and logical operations. * Demonstrate how to use boolean indexing to select elements that satisfy specific conditions. '''5. Fancy Indexing (10 mins)''' * Discuss fancy indexing as another advanced indexing technique: ** Fancy indexing allows for selecting specific elements or subarrays using integer arrays as indices. ** Show examples of using arrays of indices to select non-contiguous elements or subarrays. * Demonstrate how to use fancy indexing to achieve complex selection operations. '''6. Exercise (15 mins)''' * Provide a programming exercise where students: ** Write code to create multi-dimensional arrays and practice indexing and slicing operations. ** Use boolean indexing to filter array elements based on specified conditions. ** Experiment with fancy indexing to select specific elements or subarrays from arrays. '''7. Conclusion (5 mins)''' * Recap the key points covered in the lesson: ** Indexing and slicing are essential techniques for accessing and manipulating array data in NumPy. ** Indexing allows for accessing individual elements, while slicing enables extraction of subarrays. ** Multi-dimensional arrays can be indexed along different axes to access rows, columns, and specific elements. ** Boolean indexing and fancy indexing provide advanced methods for array selection based on conditions or integer arrays. * Encourage students to practice array indexing and slicing in their own projects and to explore additional indexing techniques for advanced array manipulation.
Summary:
Please note that all contributions to ICTED-WIKI may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
ICTED-WIKI:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
User page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
User contributions
Logs
View user groups
Special pages
Page information