The Joy of Computing using Python Week 9: Programming Assignment - Jan-Jun 2022

  NPTEL PROGRAMMING ASSIGNMENTS

The Joy of Computing Using Python

Week 9: Programming Assignment 1

Due Date of Submission 2022-03-31, 23:59 IST
Given two string s1 and s2, write a function subStr which accepts two parameters 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. 

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.




 

 

if __name__ == "__main__":
    s1 = input()
    s2 = input()
    print(subStr(s1, s2))




Week 9: Programming Assignment 2

Due Date of Submission 2022-03-31, 23:59 IST
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}



 

 



Week 9: Programming Assignment 3

Due Date of Submission 2022-03-31, 23:59 IST
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.
First number is 1 and its index is 0 therefore
1 0 

Second and third number is 2 and its index is 1,2 therefore
2 1 2

and so on...




n = int(input())

 

 


Post a Comment (0)
Previous Post Next Post