0% found this document useful (0 votes)
2 views7 pages

2D Array Study Guide Python

This study guide covers 2D arrays in Python, explaining their structure as lists of lists and providing examples of accessing and traversing elements. It outlines common operations like summing elements and real-world applications such as student marksheets and games. Additionally, it includes practice tasks to reinforce learning, such as creating matrices and analyzing data.

Uploaded by

fatimahehe31323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

2D Array Study Guide Python

This study guide covers 2D arrays in Python, explaining their structure as lists of lists and providing examples of accessing and traversing elements. It outlines common operations like summing elements and real-world applications such as student marksheets and games. Additionally, it includes practice tasks to reinforce learning, such as creating matrices and analyzing data.

Uploaded by

fatimahehe31323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

📘 Study Guide: 2D Arrays in

Python
With Real-World Applications &
Practice Solutions
1. What is a 2D Array?
• ▪ A 2D array is a list of lists in Python.
• ▪ Think of it like a table with rows and
columns.

• Example:
• matrix = [
• [1, 2, 3],
• [4, 5, 6],
• [7, 8, 9]
2. Accessing Elements
• ▪ Use row and column indexes.

• Example:
• print(matrix[0][1]) → 2
• print(matrix[2][0]) → 7
3. Traversing a 2D Array
• Row by row:
• for row in matrix:
• print(row)

• Element by element:
• for row in matrix:
• for element in row:
• print(element)
4. Common Operations
• ▪ Sum of all elements
• ▪ Sum of each row
• ▪ Sum of each column
• ▪ Finding largest element
5. Real-World Applications
• ▪ Student Marksheets (rows=students,
cols=subjects)
• ▪ Tic-Tac-Toe Game (3x3 grid)
• ▪ Images (pixels stored as numbers)
• ▪ Seating Charts (cinema, classrooms)
• ▪ Maps & GPS (cells represent locations)
6. Practice Tasks
• 1. Create a 3x3 matrix and print diagonal
elements.
• 2. Find the largest element in a 2D array.
• 3. Store marks of 4 students in 3 subjects and
find:
• ▪ Average marks of each student
• ▪ Highest marks in each subject
• 4. Create a 5x5 matrix with random numbers
and count even/odd.

You might also like