NPTEL The Joy Of Computing Using Python Week 10 Programming Assignment | NPTEL Swayam Assignment Answers
Nptel Week 10 Programming Assignment Answers:
Q.1: Given a list L, write a program to make a new list to fix the indexes of numbers in the list L to its same value in the new list. Put 0 at remaining indexes. Also print the elements of the new list in the single line. (See explanation for more clarity.)
Input:
[1,5,6]
Output:
0 1 0 0 0 5 6
Explanation:
List L contains 1,5,9 so at 1,5,9, index of new list the respective values are put and rest are initialized as zero.
Q.2: Ram shifted to a new place recently. There are multiple schools near his locality. Given the co-ordinates of Ram P(X,Y) and schools near his locality are given in a nested list, find the closest school. Print multiple coordinates in respective order if there exist multiple schools closest to him. Write a function closestSchool that accepts (X ,Y , L) where X and Y are co-ordinates of Ram's house and L contains co-ordinates of different school.
Distance Formula(To calculate distance between two co-ordinates): √((X2 - X1)² + (Y2 - Y1)²)
where (x1,y1) is the co-ordinate of point 1 and (x2, y2) is the co-ordinate of point 2.
Input:
X, Y (Ram's house co-ordinates)
N (No of schools)
X1 Y1
X2 Y2
.
.
.
X6 Y6
Output:
Closest point/points to X, Y
Q.3: Given a string s write a program to convert uppercase letters into lowercase and lowercase letters into uppercase. Also print the resultant string.
Note: You need to take the input and do not print anything while taking input.
Input:
The Joy Of Computing
Output
tHE jOY oF cOMPUTING
If you are facing any queries regarding this assignment solutions, then please drop comment in comment section.
0 Comments