Run Below Program in Python and Provide comments on the each code line what they are Doing
x = int(input(‘Enter value of x: ‘))
y = int(input(‘Enter value of y: ‘))
# Task1
def task1_function(x, y):
nested_list = []
for i in range(x):
inner_list = []
for j in range(y):
inner_list.append(0)
nested_list.append(inner_list)
return nested_list
nested_list_1 = task1_function(x, y)
print(nested_list_1)
# Task2
def task2_function(x, y):
nested_list_2 = []
for i in range(x):
inner_list_2 = []
for j in range(y):
if (i+1) % (j+1) == 0:
inner_list_2.append(1)
else:
inner_list_2.append(0)
nested_list_2.append(inner_list_2)
return nested_list_2
nested_list_2 = task2_function(x, y)
print(nested_list_2)
# Task 3
def task3_function(x, y):
for i in range(x):
for j in range(y):
if nested_list_2[i][j] == 1:
print(‘Index:’,i,j)
task3_function(x, y)
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code “Newclient”
The post Run Below Program in Python and Provide comments on the each code appeared first on Superb Professors.
Case study one page Case study one page Case study one page Case study one…
Business Calculus quiz that is 10 questions and has an hour time limit. Must be…
Write a 175- to 265-word response to the following: What constitutes “robust interoperability,†and what…
For this News Briefing Quest task , pick and analyze a U.S. political news article…
ACC 610 Milestone TwoGuidelines and Rubric This is the secondof three milestone assignments that will…
Please answer the questions in the attachment. I have sent you the required materials. Send…