NPTEL Programming Data Structures And Algorithms Using Python | NPTEL Week 2 Programming Assignment | NPTEL Assignment Solutions

NPTEL Programming, Data Structures And Algorithms Using Python Week 2 Programming Assignment | NPTEL Swayam Assignment Answers


programming data structures and algorithms using python nptel answer week 2


Nptel Week 2 Programming Assignment Answers:

write three python functions as specified below paste the text for all three functions together into the submission window

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


>>> intreverse(783)
387
>>> intreverse(242789)
987242
>>> intreverse(3)
3


write a function matched(s) that takes as input a string s

>>> matched("zb%78")
True
>>> matched("(7)(a")
False
>>> matched("a)*(?")
False
>>> matched("((jkl)78(A)&l(8(dd(FJI:),):)?)")
True


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

>>> sumprimes([3,3,1,13])
19
>>> sumprimes([2,4,6,9,11])
13
>>> sumprimes([-3,1,6])
0


Code:


If you are facing any queries regarding this assignment solutions, then please drop comment in comment section.

Post a Comment

0 Comments