Software Development Exam  >  Software Development Tests  >  Basics of Python  >  Test: 2D Arrays - 2 - Software Development MCQ

Test: 2D Arrays - 2 - Software Development MCQ


Test Description

15 Questions MCQ Test Basics of Python - Test: 2D Arrays - 2

Test: 2D Arrays - 2 for Software Development 2024 is part of Basics of Python preparation. The Test: 2D Arrays - 2 questions and answers have been prepared according to the Software Development exam syllabus.The Test: 2D Arrays - 2 MCQs are made for Software Development 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: 2D Arrays - 2 below.
Solutions of Test: 2D Arrays - 2 questions in English are available as part of our Basics of Python for Software Development & Test: 2D Arrays - 2 solutions in Hindi for Basics of Python course. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free. Attempt Test: 2D Arrays - 2 | 15 questions in 30 minutes | Mock test for Software Development preparation | Free important questions MCQ to study Basics of Python for Software Development Exam | Download free PDF with solutions
1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: 2D Arrays - 2 - Question 1

Which of the following statements about 2D arrays in Python is true?

Detailed Solution for Test: 2D Arrays - 2 - Question 1

In Python, 2D arrays can have different data types in each row. This is because each row can be considered as a separate 1D array.

Test: 2D Arrays - 2 - Question 2

What is the correct way to access an element in a 2D array in Python?

Detailed Solution for Test: 2D Arrays - 2 - Question 2

To access an element in a 2D array, we use the syntax array[i][j], where i represents the row index and j represents the column index.

Test: 2D Arrays - 2 - Question 3

What is the time complexity for accessing an element in a 2D array?

Detailed Solution for Test: 2D Arrays - 2 - Question 3

Accessing an element in a 2D array takes constant time because the position of the element is known based on the row and column indices.

Test: 2D Arrays - 2 - Question 4

Which module in Python provides functions to work with 2D arrays efficiently?

Detailed Solution for Test: 2D Arrays - 2 - Question 4

The numpy module provides efficient functions and data structures for working with arrays, including 2D arrays.

Test: 2D Arrays - 2 - Question 5

Which of the following methods can be used to iterate over all elements in a 2D array?

Detailed Solution for Test: 2D Arrays - 2 - Question 5

To iterate over all elements in a 2D array, we use nested loops. The outer loop iterates over the rows, and the inner loop iterates over the columns.

Test: 2D Arrays - 2 - Question 6

What will be the output of the following code snippet?
array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(array[1][2])

Detailed Solution for Test: 2D Arrays - 2 - Question 6

The code snippet accesses the element at row 1, column 2 in the 2D array and prints its value, which is 6.

Test: 2D Arrays - 2 - Question 7

What will be the output of the following code snippet?
array = [[1, 2], [3, 4]]
print(len(array))

Detailed Solution for Test: 2D Arrays - 2 - Question 7

The len() function returns the number of elements in the given list. In this case, it returns 2, which is the number of rows in the 2D array.

Test: 2D Arrays - 2 - Question 8

What will be the output of the following code snippet?
array = [[1, 2, 3], [4, 5, 6]]
print(sum(array[0]))

Detailed Solution for Test: 2D Arrays - 2 - Question 8

The sum() function calculates the sum of all elements in the given list. In this case, it calculates the sum of elements in the first row, which is 6.

Test: 2D Arrays - 2 - Question 9

What will be the output of the following code snippet?
array = [[1, 2, 3], [4, 5, 6]]
print(max(array[1]))

Detailed Solution for Test: 2D Arrays - 2 - Question 9

The max() function returns the maximum value from the given list. In this case, it returns 6, which is the maximum value in the second row of the 2D array.

Test: 2D Arrays - 2 - Question 10

What will be the output of the following code snippet?
array = [[1, 2], [3, 4]]
print(array[-1][-1])

Detailed Solution for Test: 2D Arrays - 2 - Question 10

The code snippet accesses the last element of the last row in the 2D array and prints its value, which is 4.

Test: 2D Arrays - 2 - Question 11

Given a 2D array "matrix" of size m x n, how would you swap the elements of the matrix diagonally?

Detailed Solution for Test: 2D Arrays - 2 - Question 11

To swap the elements of a matrix diagonally, we need to iterate over each element and swap it with its corresponding diagonal element.

Test: 2D Arrays - 2 - Question 12

Given a 2D array "matrix" of size m x n, how would you calculate the sum of all elements in the matrix?

Detailed Solution for Test: 2D Arrays - 2 - Question 12

To calculate the sum of all elements in a matrix, we can use nested loops to iterate over each element and add them together.

Test: 2D Arrays - 2 - Question 13

Given a 2D array "matrix" of size m x n, how would you find the row with the highest sum of elements?

Detailed Solution for Test: 2D Arrays - 2 - Question 13

To find the row with the highest sum of elements, we need to iterate over each row, calculate the sum of elements in each row, and keep track of the row with the highest sum.

Test: 2D Arrays - 2 - Question 14

Given a 2D array "matrix" of size m x n, how would you check if the matrix is symmetric?

Detailed Solution for Test: 2D Arrays - 2 - Question 14

To check if a matrix is symmetric, we can iterate over each element and compare it with the corresponding element in the transposed matrix. If all corresponding elements are the same, the matrix is symmetric.

Test: 2D Arrays - 2 - Question 15

Given a 2D array "matrix" of size m x n, how would you rotate the matrix 90 degrees clockwise?

Detailed Solution for Test: 2D Arrays - 2 - Question 15

To rotate a matrix 90 degrees clockwise, we need to reverse each row and then transpose the matrix.

49 videos|38 docs|18 tests
Information about Test: 2D Arrays - 2 Page
In this test you can find the Exam questions for Test: 2D Arrays - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: 2D Arrays - 2, EduRev gives you an ample number of Online tests for practice
49 videos|38 docs|18 tests
Download as PDF
Download the FREE EduRev App
Track your progress, build streaks, highlight & save important lessons and more!