NPTEL PROGRAMMING ASSIGNMENTS
The Joy of Computing Using Python
Week 8: Programming Assignment 1
Due Date of Submission 2022-03-24, 23:59 IST
Given a Tuple T, create a function squareT which accepts one argument and returns a tuple containing similar elements given in tuple T and its sqaures in sequence.
Input:
(1,2,3)
Output :
(1,2,3,1,4,9)
Explanation:
Tuple T contains (1,2,3) the output tuple contains the original elements of T that is 1,2,3 and its sqaures 1,4,9 in sequence.
Input:
(1,2,3)
Output :
(1,2,3,1,4,9)
Explanation:
Tuple T contains (1,2,3) the output tuple contains the original elements of T that is 1,2,3 and its sqaures 1,4,9 in sequence.
if __name__ == "__main__":
n = int(input())
L = list(map(int, input().split()))
T = tuple(L)
ans = squareT(T)
if type(ans) == type(T):
print(ans)
Week 8: Programming Assignment 2
Due Date of Submission 2022-03-24, 23:59 IST
Given a string S, write a function replaceV that accepts a string and replace the occurrences of 3 consecutive vowels with _ in that string. Make sure to return the answer string.
Input:
aaahellooo
Output:
_hell_
Explanation:
Since aaa and ooo are consecutive 3 vowels therefor replaced by _ .
Input:
aaahellooo
Output:
_hell_
Explanation:
Since aaa and ooo are consecutive 3 vowels therefor replaced by _ .
S = input()
print(replaceV(S))
Week 8: Programming Assignment 3
Due Date of Submission 2022-03-24, 23:59 IST
Given a list L, write a program to shift all zeroes in list L towards the right by maintaining the order of the list. Also print the new list.
Input:
[0,1,0,3,12]
Output:
[1,3,12,0,0]
Explanation:
There are two zeroes in the list which are shifted to the right and the order of the list is also maintained. (1,3,12 are in order as in the old list.)
Input:
[0,1,0,3,12]
Output:
[1,3,12,0,0]
Explanation:
There are two zeroes in the list which are shifted to the right and the order of the list is also maintained. (1,3,12 are in order as in the old list.)
n = 10
L = list(map(int, input().split()))