The Joy Of Computing Using Python Week 5 Programming Assignment

Hello everyone, we are came back with Nptel week 5 programming assignment of Joy Of Computing Using Python. In this article we will discuss the answers fo week 5 assignment . Please Use these answers as reference, If any doubt arises feel free to comment in the comment section below. Then why Waiting, Come with us, Let us solve the programming assignment. 

Also read: The Joy of computing using Python week 5 Quiz answers 

The Joy Of Computing Using Python Week 5 Programming Assignment


The Joy Of Computing Using Python Week 5 Programming Assignment 

Before going into the answers of week 5 , let briefly see the what are the topics present in Week 5 : 

  • Introduction to dictionaries
  • Speech To Text 
  • Monte Hall 
  • Rock, Paper and Scissor 
  • Sorting and Searching 

Introduction to Dictionaries: 

The dictionaries in Python are used to store data values in key: value pairs.  A dictionary is a order of collection, changeable and which do not allow duplicates. 

According to the version of Python 3.7, the dictionaries are ordered 

Example : 
                      { "department" : " ECE", " Year" : " 3rd " }

Speech to text : 

In Python, it is possible to convert from Speech to Text by using the library " PyAudio" . By Using these we can create Real Life examples like Alexa, Siri , etc. 

Monte Hall: 

It is a 3 door Twist- Monte Hall. In these concept, We have a object which is hided in the three bags. The Person has to identify the object among one of the three bags. If the person Successfully, found it then he won.  
                     At this time, the questioner tricky the identifier to choose another bag. This is how it works, you can find more detail in the Internet.

Rock, Paper and Scissor: 

Rock paper scissor I win, rock paper scissor I win, rock paper scissor draw, rock paper scissor draw hey guys what are you playing? We are playing rock paper scissor ok. What is that? This is scissor, ok this is the paper, this is the rock, rock cuts the scissor, the scissor cuts the paper and paper cuts the rock, the rock cuts the scissor, the scissor cuts the paper and paper cuts the rock did you get it? Can you explain ?You will not understand please let us play don’t waste our time don’t disturb ok please. Rock paper scissor, why are you cheating? Where did I cheat? You changed your sign just now! No no don’t lie, you show scissor then you changed to paper! No no you are simply telling, I don’t want to play with you. Hey vidya can I talk to you for few minutes? Sure. My friends were playing rock papers scissors game now I understood I goggled it. One of my friends were cheating I want to create the mechanism where no one can cheat, is there any way to do that? Well I remember having studied something like that oh yeah! In nptel there is a course called joy of computing in which actually the professor teaches a mechanism through which we can play rock paper scissors in which no one can cheat, definitely you should take a look at it. Oh yeah! Thanks vidya definitely I will take a look at it.

Sorting and Searching: 

Hey amit lets play a game, what game? It’s called twenty questions game what!!?You have to keep a number in your mind between say one to ten thousand ok and I will guess it right less than twenty attempts, less than twenty attempts!!Yeah. I don’t think it’s possible oh it is very easy. Ok the rules goes like this I will ask whether the number is less than equal to or greater than some number so you have to just say yes or no or it is less than or equal to or greater than, you will ask me whether my number is less than, equal to, greater than your some random number yeah yeah


Programming Assignment:

Let now see the Assignment Sums: 

Q1. 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.

CODE:   

import math

a = int(input())

b = int(input()) 

print(math.gcd(a,b),end=''){codeBox}

 

Q2. 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.

CODE:  

raja=[int(i) for i in input().split()]

rani=[int(i) for i in input().split()] 

def dot_product(Romio, Juliet ):

  return(sum([Romio[i]*Juliet[i]  for i in range(len(Romio))]))   

print(dot_product(raja,rani),end=""){codeBox}


Q3.Write a Python function that takes a string s as input and returns the length of the largest streak of 0s 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.  


CODE:  

def largest_zero_streak(mystring):

    return(len(max(mystring.split('1'))))

s=input()

print(largest_zero_streak(s),end="")  {codeBox}

 

Also Read: The Joy Of Computing Using Python Week 5 Quiz Answers

Conclusion: 

I Request everyone to revisit the website on/before to last date for any re-verification of answers.
 
If you have any queries, contact us. I am very thankful to answer you.
 
NOTE: I'm answering these questions to the best of my knowledge.

One Comment Please !

Post a Comment (0)
Previous Post Next Post