**Programming Data Structures And Algorithms Using Python Coding Assignment 2 Answers**:- Hello students in this article we are going to share NPTEL Programming Data Structures And Algorithms Using Python assignment week 2 answers. All the Answers provided below to help the students as a reference, You must submit your assignment at your own knowledge.

**Below you can find Programming Data Structures And Algorithms Using Python Coding Assignment 2 Answers**

Assignment No. | Answers |
---|---|

Programming Data Structures And Algorithms Using Python Assignment 1 | Click Here |

Programming Data Structures And Algorithms Using Python Assignment 2 | Click Here |

Programming Data Structures And Algorithms Using Python Assignment 3 | Click Here |

Programming Data Structures And Algorithms Using Python Assignment 4 | Click Here |

Programming Data Structures And Algorithms Using Python Assignment 5 | Click Here |

Programming Data Structures And Algorithms Using Python Assignment 6 | Click Here |

Programming Data Structures And Algorithms Using Python Assignment 7 | Click Here |

Programming Data Structures And Algorithms Using PythonAssignment 8 | Click Here |

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

**Q1. **Write a function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n.

Write a function matched(s) that takes as input a string s and checks if the brackets “(” and “)” in s are matched: that is, every “(” has a matching “)” after it and every “)” has a matching “(” before it. Your function should ignore all other symbols that appear in s. Your function should return True if s has matched brackets and False if it does not.

Write a function sumprimes(l) that takes as input a list of integers l and retuns the sum of all the prime numbers in l.

**Code:-**

**For week 2 quiz assignment click here**

```
def intreverse(n):
ans = 0
while n > 0:
(d,n) = (n%10,n//10)
ans = 10*ans + d
return(ans)
def matched(s):
nested = 0
for i in range(0,len(s)):
if s[i] == "(":
nested = nested+1
elif s[i] == ")":
nested = nested-1
if nested < 0:
return(False)
return(nested == 0)
def factors(n):
factorlist = []
for i in range(1,n+1):
if n%i == 0:
factorlist = factorlist + [i]
return(factorlist)
def isprime(n):
return(factors(n) == [1,n])
def sumprimes(l):
sum = 0
for i in range(0,len(l)):
if isprime(l[i]):
sum = sum+l[i]
return(sum)
```

**Next Week Assignment Answers**

**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.