Categories: Uncategorized

Run Below Program in Python and Provide comments on the each code

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.

"Order a Custom Paper on Similar Assignment! No Plagiarism! Enjoy 20% Discount"

Superbprofessors

Recent Posts

case study one page case study one page case study one page case study one page case study one page

Case study one page Case study one page Case study one page Case study one…

2 years ago

business calculus quiz

Business Calculus quiz that is 10 questions and has an hour time limit. Must be…

2 years ago

hnif 355 disscussion post

Write a 175- to 265-word response to the following: What constitutes “robust interoperability,” and what…

2 years ago

news briefing quest 2

For this News Briefing Quest task , pick and analyze a U.S. political news article…

2 years ago

acc610 final project milestone two critical element ii analysis of financial statements

ACC 610 Milestone TwoGuidelines and Rubric This is the secondof three milestone assignments that will…

2 years ago

write in complete paragraphs 5 pages

Please answer the questions in the attachment. I have sent you the required materials. Send…

2 years ago