NPTEL The Joy of Computing Using Python Week5 Assignment 2023

The-Joy-of-Computing-using-Python-Week5-Programming-Assignmnet-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 5 Assignment 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 : write a Python program that finds the Greatest Common Divisor (GCD) of two numbers. Your program should take two input numbers from the user, and use a function named ‘gcd’ to find the GCD of those two numbers. Your program should then print out the GCD of the two numbers as the output.

				
					from math import gcd

x = int(input())
y = int(input())

print(gcd(x, y), end="")
				
			

Programming Assignment 2

Question 2 : Write a Python program that calculates the dot product of two lists containing the same number of elements. The program should take two lists of integers as input from the user, and then call a function named dot_product to find the dot product of the two lists. The dot_product function should take two lists a and b as input, and should return the dot product of those two lists.

Your program should first prompt the user to enter the two lists of integers, which should be entered as strings separated by spaces. Your program should then convert the input strings into lists of integers. Your program should then call the dot_product function with the two lists as arguments, and store the resulting dot product in a variable named result. Finally, your program should print out the dot product of the two lists as the output.
 
You can assume that the two input lists will always contain the same number of elements. Your program should output an error message and exit gracefully if the two lists have different lengths.

In your implementation, you should define the dot_product function using a loop to calculate the dot product of the two input lists.
				
					a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()] 

def dot_product(m, n ):
  return(sum([m[i]*n[i]  for i in range(len(m))]))   
  
print(dot_product(a,b),end="")
				
			

Programming Assignment 3

Question 3 : Write a Python function that takes a string s as input and returns the length of the largest streak of 0’s in the string. For example, if the input string is “10001000110000000001”, the function should return 6.

Input : The input string s is guaranteed to contain only 0s and 1s.
 
Output : The function should return an integer, representing the length of the largest streak of 0s in the input string.Your program should also print the result.
 
Sample output :
largest_zero_streak(“10101010”) => 1
largest_zero_streak(“10000010001”) => 5
largest_zero_streak(“1111”) => 0
largest_zero_streak(“0000”) => 4
largest_zero_streak(“00000000001111111111”) => 10
				
					def largest_zero_streak(input_string):
    return(len(max(input_string.split('1'))))
str=input()
print(largest_zero_streak(str),end="")