Nptel The Joy Of Computing Using Python | NPTEL Week 9 Programming Assignment | NPTEL Assignment Solutions

NPTEL The Joy Of Computing Using Python Week 9 Programming Assignment | NPTEL Swayam Assignment Answers 


nptel the joy of computing using python



Join Us On Telegram

👇👇👇👇👇👇
telegram

Join Us On Youtube

👇👇👇👇👇👇

youtube



Nptel Week 9 Programming Assignment Answers:


Q.1: Given two strings s1 and s2, write a function subStr that accepts two strings s1 and s2 and will return True if a s2 is a substring of s1 otherwise return False. A substring is a is a contiguous sequence of characters within a string. check input and output following:

Input:

bananamania
nana

Output:
True

Explanation:

S2 which is nana is in bananamania hence it is a substring of s1.

Example 2:

Input:

aabbcc
abc

output:
False

Explanation:

String s1 does not contain string s2 hence the answer is false.


Code:






Q.2: Given two dictionaries d1 and d2, write a function mergeDic that accepts two dictionaries d1 and d2 and return a new dictionary by merging d1 and d2. 
Note: Contents of d1 should be appear before contents of d2 in the new dictionary and in same order. In case of duplicate value retain the value present in d1.

Input:
{1: 1, 2: 2}
{3: 3, 4: 4}

output:
{1: 1, 2: 2, 3: 3, 4: 4}



Code:





Q.3: Given an integer n, print all the indexes of numbers in that integer from left to right.

Input:
122345

Output:
1 0 
2 1 2
3 3
4 4
5 5

Explanation:

Given integer 122345. Now printing indexes of numbers from left to right.
The First number is 1 and its index is 0 therefore
1 0 


The second and the third number is 2 and its index is 1,2 therefore
2 1 2

and so on...



Code:





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

Post a Comment

0 Comments