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

 NPTEL PROGRAMMING ASSIGNMENTS

The Joy of Computing Using Python

Week 6: Programming Assignment 1

Due Date of Submission 2022-03-10, 23:59 IST
Aman likes to study about planets. Every night he goes outside and observe some planets with his telescope. Then he guesses the distance of each planet and pen it down. In this process he also pen down his favourite planet position. Given the distance of each planet to be unique you need to return position of Aman's favourite planet after sorting all the distances.

Input:

N (No of planets)
L (List of distances of planet)
K (position of Aman's favourite planet in unsorted list)

Output:

Position of Aman's favourite planet in sorted List.

Example:

Input
5
[4,5,3,2,1]
2

Output
5

Explanation:

The position of aman's favourite planet in unsorted list is 2 and list of distances of planets at position 2 the distance is 5. After sorting the list [1,2,3,4,5] the position of aman's favourite is changed to 5.

Note: Index is different from position. Indexing of the list starts from 0 whereas positioning in the list start form 1.



N = int(input())
L = [int(i) for i in input().split()]
K = int(input())




 

 



Week 6: Programming Assignment 2

Due Date of Submission 2022-03-10, 23:59 IST
Romeo and Juliet love each other. Romeo wants to send a message to Juliet and also don't want anyone to read it without his permission. So he shifted every small letter in the sentence by -2 position and every capital letter by -3 position. (If the letter is c, after shifting to by -2 position it changes to a, and for D new letter will be A).
But the letter is too long and Romeo does not have enough time to encrypt his whole letter. Write a program to help Romeo which prints the encrypted message. You can assume there are no special characters except spaces and numeric value.

Input
A string S 

Output 
Encrypted string 

Example

Input
Hello Juliet

Output
Ecjjm Gsjgcr

Explanation
H is shifted by -3 position and changed to E. 'e' is shifted by -2 position and changed to c and so on.



S = input()


 

 




Week 6: Programming Assignment 3

Due Date of Submission 2022-03-10, 23:59 IST
write a function whole(N) which takes a number N and return the sum of first N whole number. Write the program using recursion.

Input
N

Output
sum of whole numbers till N

Example:

Input
3

Output
6

Explanation 
Sum of first 3 natural numbers are 0+1+2+3 = 6



 

 

N = int(input())
print(whole(N))


Post a Comment (0)
Previous Post Next Post