Question-138: When you run below code, it would

temps = [[1 for i in range(3)] for j in range(5)]

print(temps)

 

  1. Generate 2-dimensional list of size 5X3
  2. Get all Questions and Answer from here
  3. You need to have paid subscription to access all questions
  4. Thanks for considering Python Certification Material

 

Answer: A

Exp:

List comprehension

Below code will generate 2-dimensional list of size 5X3

  • 5 rows
  • Each row has 3 elements in it.
  • Value of each element is 1

temps = [[1 for i in range(3)] for j in range(5)]

print(temps)

 

Below code will generate 3 dimensional list of size 5X3X2

  • There is no limit for dimension you can create for a matrix.

temps = [[[1 for i in range(3)] for j in range(5)] for k in range(2)]

print(temps)

 

You can access to full explanation to question and answer from this page.

Why Dont you prepare for Python Certifications and Interview Questions with 250+ Questions and Answer : Check Here

Real Exam Number of Questions: 70 Questions
Real Exam Pass Score: 70%
Time Allotted: 90 minutes to complete exam