The Joy of Computing using Python Week 10: Programming Assignment - Jan-Jun 2023

    NPTEL PROGRAMMING ASSIGNMENTS

The Joy of Computing Using Python

Week 10 Programming Assignment 1
Last Day of Submission: 06-Apr-2023
Given a list L write a program to make a new list to fix the indexes of numbers to in 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.


the joy of computing using python


 

  





Week 10 Programming Assignment 2
Last Day of Submission: 06-Apr-2023

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 in a nested list, find the closest school. Print multiple coordinates in respective order if there exists 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 pont/points to X, Y


the joy of computing using python


 

  

x, y = map(int, input().split())
n = int(input())
L = []
for i in range(n):
    l = list(map(int, input().split()))
    L.append(l)
closestSchool(x, y, L)





Week 10 Programming Assignment 3
Last Day of Submission: 06-Apr-2023

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 talk the input and do not print anything while taking input.

Input:
The Joy Of Computing

Output
tHE jOY oF cOMPUTING

the joy of computing using python


 

  


Post a Comment (0)
Previous Post Next Post