NPTEL The Joy Of Computing Using Python Week 8 Assignment

The-Joy-of-Computing-using-Python-Week8-Programming-Assignment-Solutions

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 Week 8 Assignment.

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 : Write a function cubeT that accepts a list L and returns a tuple containing cubes of elements of L.

Input
A tuple T

Output 
Cube of T

				
					def cubeT(l):
  res = tuple([pow(i, 3) for i in l])
  return res
  
L = [int(i) for i in input().split()]
print(cubeT(L))
				
			

Programming Assignment 2

Question 2 : 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_

				
					def isvowel(ch):
    v = 'AEIOUaeiou'
    if ch in v:
        return True
    else:
        return False

def replaceV(s):
    n = len(s)
    ans = ''
    i=0
    while(i<n-2):
        if isvowel(s[i]) and isvowel(s[i+1]) and isvowel(s[i+2]):
            ans = ans+'_'
            i = i+3 
        else:
            ans = ans+s[i]
            i = i+1    
    return ans+s[i:]
    
S = input()
print(replaceV(S))
				
			

Programming Assignment 3

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

				
					L = list(map(int, input().split()))

zeroes = L.count(0)
i = 0
while i < len(L)-zeroes:
    if L[i] == 0:
        L.pop(i)
        L.append(0)
        i -= 1
    i += 1
print(L,end="")