Respuesta :
Answer:
N = [1,1,1,1,1],
[2,2,2,2,2],
[3,3,3,3,3],
[4,4,4,4,4]
def printIt(ar):
for row in range(len(ar)):
for col in range(len(ar[0])):
print(ar[row][col], end=" ")
print("")
N=[]
for r in range(4):
N.append([])
for r in range(len(N)):
value=1
for c in range(5):
N[r].append(value)
value=value + 1
printIt(N)
print("")
newValue=1
for r in range (len(N)):
for c in range(len(N[0])):
N[r][c] = newValue
newValue = newValue + 1
printIt(N)
Explanation:
:D
Below is the required program of Python.
Python
Program:
# Array name will be "N".
# Start program
# Defining a function and taking input array
def printIt(ar):
# Using for loop to scan the rows as well as columns of array
for row in range(len(ar)):
for col in range(len(ar[0])):
# Printing the element of array
print(ar[row][col], end=" ")
print("")
# Passing the array N
N=[]
# Again using the loop
for r in range(4):
N.append([])
# Loop to control rows
for r in range(len(N)):
value=1
# Loop to control columns
for c in range(5):
N[r].append(value)
value=value + 1
# Calling the function
printIt(N)
print("")
newValue=1
# Value in row and column
for r in range (len(N)):
for c in range(len(N[0])):
# Assigning the values to the array
N[r][c] = newValue
newValue = newValue + 1
# Printing the array
# End program
printIt(N)
Program code:
- Start a program.
- Defining a function and taking input array
- Using for loop to scan the rows as well as columns of array
- Printing the element of array
- Again using the loop to control rows and columns.
- Assigning the values to the array
- End program.
Output:
Find below the attachment of the output of the program code.
Find out more information about Python here:
https://brainly.com/question/26497128
