The Joy of Computing with Python Unproctored exam (8-9PM) Review |Question paper and answer given

Swayam portal logo

     Basically the evening session is lighter tough for me. I solved in half an hour. If you did not see the morning session review. First read that and come back for to read this article.

     *Also Read -> Joc morning session review (question and answer included) 

     *Also Read -> Joc Proctored exam (Dec 19, 2020) Review

     Now we are going to see the question and answer(my solution) for evening session. This blog will help for upcoming batches, to know how was the unproctored exam.  This is open resource exam and 1 hour duration. 


     In future batches they may ask more questions or less questions but any number of questions they ask that can be solved within 1hour. Because they fix the questions in that way. For this session (Dec 2020) morning 8-9PM Unproctored exam, they asked only one question to solve.


     This is for only educational purpose. The question and answer for the exam  in this blog is posted  only after the exam is completed i.e. after 9 pm for morning session.

Question paper and answer for unproctored exam 8-9PM

Programming exam 2: Word count

You are given some words. Some of them may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification.

All the words are composed of lowercase English letters only.

Input Format

It should contain all the words separated by space.

Output Format

Output the number of distinct words from the input  
Output the number of occurrences for each distinct word according to their appearance in the input.
Both the outputs should be separated by space.

Sample Input

bcdef abcdefg bcde bcdef

Sample Output

3 211


There are distinct words. Here, "bcdef" appears twice in the input at the first and last positions. The other words appear once each. The order of the first appearances are "bcdef", "abcdefg" and "bcde" which corresponds to the output.

Answer (my own solution) :
num=len(a)     #finding the number of distinct words
for i in a:
  for j in range(len(n)):
    if i==n[j]:
  d[i]=count     #finding the count of repeated words
for i in n:
  for j in d.keys():
    if i==j:
      b[i]=d[j]      #arranging the count of words according to the given order in input
for i in b.values():
  f=f+i       #joining the count together

     This answer passed in both public and private test cases.  There are many ways to solve this problem not only this.

     *Also Read  -> Joc Proctored exam (Dec 19, 2020) Review
Content Last Updated on 5th August 2021, 3:00 PM IST

Post a Comment

Previous Post Next Post