The Joy of Computing using Python Week 8 Assignment

                     

Course name: The Joy of Computing Using Python

Link to Enroll: Click here

This is an assignment for The Joy of Computing using Python Week 8 Assignment


Q1. Which of the following q43 the correct representation of tuples?
a) [1,2,3,4]
b) (1,2,3,4)
c) ((1), (2), (3), (4))
d) [[1], [2], [3], [4]]

Answer: b), c)


Q2. Why gambling is not recommended?
a) Because you lose every time.
b) Because you win every time.
c) Because the loss amount is greater than the winning amount over time.
d) Because the winning amount is greater than the loss amount over time.

Answer: c) Because the loss amount is greater than the winning amount over time.


This is an assignment for The Joy of Computing using Python Week 8 Assignment


Q3. Which of the following programs will print the exact same word?

Answer: a), c)


Q4. Using which of the following methods a person can store over a million images in small digital storage?
a) Decompression
b) Compression
c) Enhancement
d) UnzipSHOW ANSWER

Answer: b) Compression


This is an assignment for The Joy of Computing using Python Week 8 Assignment


Q5. State True or False, A lot of information can be revealed from images by using the right kind of enhancement.
a) True
b) False

Answer: a) True


Q6. type(10) will return?
a) int
b) str
c) float
d) list

Answer: a) int


Q7. Which of the following pair of words are anagrams?
a) A gentleman, Elegant man
b) Cat, Arc
c) Looted, Toledo
d) Monasteries, Aman stories

Answer: a), c)


This is an assignment for The Joy of Computing using Python Week 8 Assignment


Q8. Using PIL how an image ‘img’ can be flipped?
a) img.flip()
b) img.rotate()
c) img.transpose()
d) img.turn()

Answer: a) img.flip()


Q9. What is the purpose of NLTK?
a) To process binary language.
b) To process foreign language.
c) To process human language.
d) To process only Hindi language

Answer: c) To process human language.


Q10. How does Vader help in sentiment analysis?
a) It calculates whether the statement is negative, positive, or neutral.
b) It takes care of the intensity of a statement.
c) Both A and B
d) None of the above

Answer: c) Both A and B


This is an assignment for The Joy of Computing using Python Week 8 Assignment


Programming Assignment

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

Solution:

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))

This is an assignment for The Joy of Computing using Python Week 8 Assignment


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_

Solution:


This is an assignment for The Joy of Computing using Python Week 8 Assignment


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))

This is an assignment for The Joy of Computing using Python Week 8 Assignment


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]

Solution:

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="")

This is an assignment for The Joy of Computing using Python Week 8 Assignment

More Weeks solutions of this course: https://progies.in/answers/nptel/the-joy-of-computing-using-python

More NPTEL Solution: https://progies.in/answers/nptel


* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first.


This is an assignment for The Joy of Computing using Python Week 8 Assignment