NPTEL The Joy Of Computing Using Python Week6 Assignment July 2023

NPTEL-The-Joy-Of-Computing-Using-Python-Week6-Assignment-July-2023

NPTEL Course a fun filled whirlwind tour of 30 hrs, covering everything you need to know to fall in love with the most sought after skill of the 21st century. The course brings programming to your desk with anecdotes, analogies and illustrious examples. Turning abstractions to insights and engineering to art, the course focuses primarily to inspire the learner’s mind to think logically and arrive at a solution programmatically. As part of the course, you will be learning how to practice and culture the art of programming with Python as a language. At the end of the course, we introduce some of the current advances in computing to motivate the enthusiastic learner to pursue further directions. The Joy of Computing using python is a fun filled course offered by NPTEL.

The Joy Of Computing Using Python Week6 Assignment July 2023

INTENDED AUDIENCE :  Any interested audience
PREREQUISITES :  10th standard/high school
INDUSTRY SUPPORT :  Every software company is aware of the potential of a first course in computer science. Especially of a first course in computing, done right.

Course Layout

  • Motivation for Computing
  • Welcome to Programming!!
  • Variables and Expressions : Design your own calculator
  • Loops and Conditionals : Hopscotch once again
  • Lists, Tuples and Conditionals : Lets go on a trip
  • Abstraction Everywhere : Apps in your phone
  • Counting Candies : Crowd to the rescue
  • Birthday Paradox : Find your twin
  • Google Translate : Speak in any Language
  • Currency Converter : Count your foreign trip expenses
  • Monte Hall : 3 doors and a twist
  • Sorting : Arrange the books
  • Searching : Find in seconds
  • Substitution Cipher : What’s the secret !!
  • Sentiment Analysis : Analyse your Facebook data
  • 20 questions game : I can read your mind
  • Permutations : Jumbled Words
  • Spot the similarities : Dobble game
  • Count the words : Hundreds, Thousands or Millions.
  • Rock, Paper and Scissor : Cheating not allowed !!
  • Lie detector : No lies, only TRUTH
  • Calculation of the Area : Don’t measure.
  • Six degrees of separation : Meet your favourites
  • Image Processing : Fun with images
  • Tic tac toe : Let’s play
  • Snakes and Ladders : Down the memory lane.
  • Recursion : Tower of Hanoi
  • Page Rank : How Google Works !!

Programming Assignment 1

Question 1 : 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 : 5
            [4,5,3,2,1]
            2

Output : 5

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

favorite_distance = L[K - 1]
sorted_distances = sorted(L)
favorite_position = sorted_distances.index(favorite_distance) + 1

print(favorite_position, end="")
				
			

Programming Assignment 2

Question 2 : 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 : Hello Juliet

Output : Ecjjm Gsjgcr

				
					S = input()

def encrypt_message(message):
    encrypted = ''
    
    for char in message:
        if char.islower():
            encrypted_char = chr(((ord(char) - ord('a') - 2) % 26) + ord('a'))
        elif char.isupper():
            encrypted_char = chr(((ord(char) - ord('A') - 3) % 26) + ord('A'))
        else:
            encrypted_char = char
        encrypted += encrypted_char
    
    return encrypted

# Encrypt the message and print the result
encrypted_message = encrypt_message(S)
print(encrypted_message,end="")

				
			

Programming Assignment 3

Question 3 : 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 : 3

Output : 6

				
					def whole(N):
    if N == 0:
        return 0
    else:
        return N + whole(N - 1)
        
N = int(input())
print(whole(N))