# Programming Data Structures And Algorithms Using Python Assignment 2 Answers 2022

Are you looking for the Answers to NPTEL Programming Data Structures And Algorithms Using Python Assignment 2? This article will help you with the answer to the National Programme on Technology Enhanced Learning (NPTEL) Course “ NPTEL Programming Data Structures And Algorithms Using Python Assignment 2

## What is Programming Data Structures And Algorithms Using Python?

While hard skills teach us what to do, soft skills tell us how to apply our hard skills in a social environment. The focus of the course is to develop a wide variety of soft skills starting from communication, to working in different environments, developing emotional sensitivity, learning creative and critical decision making, developing awareness of how to work with and negotiate with people and to resolve stress and conflict in ourselves and others.
The uniqueness of the course lies in how a wide range of relevant issues are raised, relevant skills discussed and tips for integration provided in order to make us effective in workplace and social environments.

## CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.

Below you can find the answers for Programming Data Structures And Algorithms Using Python Assignment 2

## Programming Data Structures And Algorithms Using Python Assignment 2 Answers:-

Q1. One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)

``````x = [1,"abcd",2,"efgh",[3,4]]  # Statement 1
y = x[0:6]                     # Statement 2
z = x                          # Statement 3
w = y                          # Statement 4
x[1] = x[1][0:3] + 'd'         # Statement 5
y[2] = 4                       # Statement 6
z[1][1:3] = 'yzw'              # Statement 7
z[0] = 0                       # Statement 8
w[4][0] = 1000                 # Statement 9
a = (x[4][1] == 4)             # Statement 10``````

Answer:- 7

Q2. Consider the following lines of Python code.

``````x = [423,'b',37,'f']
u = x[1:]
y = u
w = x
u = u[0:]
u[1] = 53
x[2] = 47``````

Answer:- A

???? Next Week Answers: Assignment 03 ????

Q3. What is the value of second after executing the following lines?

```first = "tarantula"
second = ""
for i in range(len(first)-1,-1,-1):
second = first[i] + second```

Answer:- ‘tarantula’

Q4. What is the value of list1 after the following lines are executed?

``````def mystery(l):
l = l[0:5]
return()

list1 = [44,71,12,8,23,17,16]
mystery(list1)``````

Answer:- [44,71,12,8,23,17,16]

## Programming Assignment:-

Q1. A positive integer m can be expresseed as the sum of three squares if it is of the form p + q + r where p, q, r ≥ 0, and p, q, r are all perfect squares. For instance, 2 can be written as 0+1+1 but 7 cannot be expressed as the sum of three squares. The first numbers that cannot be expressed as the sum of three squares are 7, 15, 23, 28, 31, 39, 47, 55, 60, 63, 71, … (see Legendre’s three-square theorem).

Write a Python function threesquares(m) that takes an integer m as input and returns True if m can be expressed as the sum of three squares and False otherwise. (If m is not positive, your function should return False.)

NPTEL Programming Data Structures And Algorithms Using Python Assignment 1 Answers 2022

Code:-

``````def threesquares(m):
bank=[7, 15, 23, 28, 31, 39, 47, 55,
60, 63, 71, 79, 87, 92, 95, 103,
111, 112, 119, 124, 127, 135, 143,
151, 156, 159, 167, 175, 183,
188, 191, 199, 207, 215, 220,
223, 231, 239, 240, 247, 252, 255]
return(m not in bank)

def repfree(s):
return(len(s)==len(set(s)))

def hillvalley(l):
dec = False
inc = False
c = 0
for i in range(len(l)-1):
if c > 1:
return False
right = l[i+1]
middle = l[i]
diff = right - middle
if diff > 0:
if dec:
c += 1
inc = True
dec = False
elif diff < 0:
if inc:
c += 1
dec = True
inc = False
if c == 1:
return True
return False``````

For other courses answers:- Visit

For Internship and job updates:- Visit

Disclaimer: We do not claim 100% surety of answers, these answers are based on our sole knowledge, and by posting these answers we are just trying to help students, so we urge do your assignment on your own.

if you have any suggestions then comment below or contact us at [email protected]

If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.