Query for Mock Question 2-4 (doCounting)

467 views
Skip to first unread message

Adnan Jamil

unread,
Nov 12, 2020, 12:06:44 PM11/12/20
to Discussion forum for Computational Thinking
What do we mean by P and Q as False. Why did we set it as False and what does it mean in the pseudocode. 

Please help me with the logic of setting 
P= False, Q=False

thank  you

Krishna G

unread,
Nov 12, 2020, 12:17:11 PM11/12/20
to Discussion forum for Computational Thinking, Adnan Jamil
We are initialization a variable P and Q as false, ( Similar to count = 0 ) now we we read the code, line 6 If (x.part of speech == "Pronoun" and Q 

Means the word should be pronoun and False, so the First pronoun word will become false so it wont count, it will continue to line 7 and in line 18 we are making Q = True, so it will calculate all the pronoun expect the first one.

Regards,
Krishna.G

Adnan Jamil

unread,
Nov 12, 2020, 12:23:45 PM11/12/20
to Discussion forum for Computational Thinking, krish...@gmail.com, Adnan Jamil
Hi Krishna, 

Thank you for your response and the explanation. 

Can you please help me with the lecture out of 4 weeks study material in which we were taught to initialize variable as Boolean 
Eg A=True, B=False etc. 

I will really appreciate it. 

811_BaEco_Eve_5 Sxc

unread,
Nov 12, 2020, 12:36:07 PM11/12/20
to Krishna G, Discussion forum for Computational Thinking, Adnan Jamil
Hey can you please explain how c value was calculated

--
You received this message because you are subscribed to the Google Groups "Discussion forum for Computational Thinking" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cs1001-discus...@nptel.iitm.ac.in.
To view this discussion on the web visit https://groups.google.com/a/nptel.iitm.ac.in/d/msgid/cs1001-discuss/6fd27e57-0ce0-40d3-ad62-558826e37e10n%40nptel.iitm.ac.in.

Krishna G

unread,
Nov 12, 2020, 6:40:56 PM11/12/20
to 811_BaEco_Eve_5 Sxc, Discussion forum for Computational Thinking, Adnan Jamil
I used the same approach to calculate C and also there was a question replacing and with Or, in that case it will calculate the first one.

Adnan

Good question but In my opinion AND is a Boolean operation also what I feel about true, false that they have stated is the result or the outcome, anyway I will check one more time.

BTW, how was the stats test, I found it much tougher than covid.

811_BaEco_Eve_5 Sxc

unread,
Nov 12, 2020, 9:23:54 PM11/12/20
to Krishna G, Discussion forum for Computational Thinking, Adnan Jamil
The stats paper was soo lengthy and very differently from all the assignment we have done.for finding the value of c what did if (P)mean as P was just written false pls help

DHARMA TEJA GODUMALA

unread,
Nov 13, 2020, 1:12:45 AM11/13/20
to Discussion forum for Computational Thinking, pallavi...@gmail.com, Discussion forum for Computational Thinking, Adnan Jamil, krish...@gmail.com
IF (True) then only you will enter into that if loop
If (False) you will skip that if loop.

Lokesh Jadhav

unread,
Nov 13, 2020, 4:10:38 AM11/13/20
to Discussion forum for Computational Thinking, krish...@gmail.com
thank you, your explanation is really helpful,  Would you like to explain Q.6 how line 10 is wrong. please help

Malabika Guha Mustafi

unread,
Nov 13, 2020, 6:06:18 AM11/13/20
to Discussion forum for Computational Thinking, Lokesh Jadhav, krish...@gmail.com
The condition was to check sum of the subject difference  whether equal to total difference. Definitely, the expression was not right to check the condition .

AC

unread,
Nov 13, 2020, 6:17:39 AM11/13/20
to Discussion forum for Computational Thinking, krish...@gmail.com, Adnan Jamil
Hi 

Please excuse my query:

Doesn't below code mean that B will get incremented ONLY WHEN the condition Q=TRUE (AND when the word is a Pronoun)?

111.png


Can anyone kindly confirm this?

Thanks in advance.

Best Regards,

Anirban



Malabika Guha Mustafi

unread,
Nov 13, 2020, 6:23:32 AM11/13/20
to Discussion forum for Computational Thinking, AC, krish...@gmail.com, Adnan Jamil
Yes. 
Message has been deleted

Malabika Guha Mustafi

unread,
Nov 13, 2020, 6:28:20 AM11/13/20
to Discussion forum for Computational Thinking, Malabika Guha Mustafi, AC, krish...@gmail.com, Adnan Jamil
@Ac In line 18, Q is assigned as True. So B will take all pronouns' counting except first one for each sentence{ since during end word counting again Q is assigned as False in line  21).

AC

unread,
Nov 13, 2020, 6:48:16 AM11/13/20
to Discussion forum for Computational Thinking, Malabika Guha Mustafi, AC, krish...@gmail.com, Adnan Jamil
OK, then in Q: 5:
"If the and operator in Line 6 is replaced by the or operator, then what will the value of B represent at the end of the procedure?"
111.png
then B will get incremented irrespective of the fact if Q is true or false, as long as the word = Pronoun?
That is, B will now calculate the letter-count of ALL pronouns, including the first one for each sentence, right?
i.e  if the sentence begins with a Pronoun, then letter-count that too will get counted in B; as opposed to the previous case, is that correct?

Thanks in advance.

Best.
Message has been deleted

Malabika Guha Mustafi

unread,
Nov 13, 2020, 7:00:12 AM11/13/20
to Discussion forum for Computational Thinking, AC, Malabika Guha Mustafi, krish...@gmail.com, Adnan Jamil
Yes, All pronouns and all other words also but excluding the beging word if it is not pronoun.[ Then both the or operation is false].

AC

unread,
Nov 13, 2020, 11:17:59 AM11/13/20
to Discussion forum for Computational Thinking, Malabika Guha Mustafi, AC, cs1001-...@nptel.iitm.ac.in
Thanks a ton for the clarification!

So if I understood you correctly then the next bit of code:

112.png

means that C will only be incremented IFF the word on the card is a Noun AND that P =TRUE, right?

Best.

Message has been deleted

Malabika Guha Mustafi

unread,
Nov 13, 2020, 11:39:46 AM11/13/20
to Discussion forum for Computational Thinking, AC, Malabika Guha Mustafi, cs1001-...@nptel.iitm.ac.in
Yes, but it is calculating only consecutive nouns excluding the first word( since, first P=false but if it is noun then without incrementing it will take P= true from line 13) .
next word if it is noun (consecutive ) then increment C but if it is not then p=false (from line 16)


AC

unread,
Nov 13, 2020, 11:43:43 AM11/13/20
to Malabika Guha Mustafi, Discussion forum for Computational Thinking
Great!👍

Then if I have 2 sentences like: "Joe Biden Junior has ousted Donald Trump. Hunter Biden is Joe's son" - in that order and feed it to this part of the code:

In such a case: C will contain letter-counts for "Biden, Junior" and "Trump,Hunter, Biden" and "son". Is that it?
Notice, the lettercount ran over a full stop (.)  in the "Trump,Hunter, Biden"  case as the last word of the 1st sentence and the 1st word word of the 2nd sentence (being consecutive nouns) ought to get counted in C variable, right?

Best.
Message has been deleted

Malabika Guha Mustafi

unread,
Nov 13, 2020, 12:14:57 PM11/13/20
to Discussion forum for Computational Thinking, AC, Discussion forum for Computational Thinking, Malabika Guha Mustafi
Yes, since P is not affected by fullstops then it'll be executed as per your assumption.

Srinath Sai

unread,
Nov 13, 2020, 1:08:14 PM11/13/20
to Discussion forum for Computational Thinking, Malabika Guha Mustafi, AC, Discussion forum for Computational Thinking


Is the extension of the Q loop as highlighted in yellow colour below from Line 6 to Line 17?
So, at Line 6, since Q's initial value is False, it doesn't enter this yellow-coloured loop at all, and just directly jumps to Line 18 where Q's value will be changed to "True"  and it continues thereafter for the subsequent cards. Am I right? 

1    Procedure doCounting

 2 A=0, B=0; C=0

3      P = False, Q = False

4       while (Table 1 has more rows) {

5       Read the first row X in Table 1

6       If (X.PartOfSpeech == "Pronoun" and Q) {

7       B = B+X.LetterCount

8       }

9       If (X.PartOfSpeech == "Noun") {

10     if (P) {

11     C = C+X.LetterCount

12     }

13     P = True

14     }

15     else {

16     P = False

17     }

18     Q = True

19     if (X. Word ends with a full stop) {

20     A = A+X.LetterCount

21     Q = False

22     }

23     Move X to Table 2

24     }

25     return ([A, B, C])

26 End doCounting

 

 

Malabika Guha Mustafi

unread,
Nov 13, 2020, 1:11:10 PM11/13/20
to Srinath Sai, Discussion forum for Computational Thinking, AC
No..

Malabika Guha Mustafi

unread,
Nov 13, 2020, 1:16:01 PM11/13/20
to Srinath Sai, Discussion forum for Computational Thinking, AC
First if loop starts at 6 and ends at 8. Second if is not nested within first.
Anyhow since P and Q   are false at first so for initial word both if loop will not counted.

On Fri, 13 Nov 2020, 23:38 Srinath Sai, <saisr...@gmail.com> wrote:

Srinath Sai

unread,
Nov 13, 2020, 1:24:51 PM11/13/20
to Discussion forum for Computational Thinking, Malabika Guha Mustafi, Discussion forum for Computational Thinking, AC, Srinath Sai
Thank you!

gorthi lakshmisahitya

unread,
Nov 14, 2020, 12:42:16 AM11/14/20
to Discussion forum for Computational Thinking, saisr...@gmail.com, Malabika Guha Mustafi, Discussion forum for Computational Thinking, AC
Hi guys 
I am Sahitya . My doubts were also the same as stated above.
Hence, the above conversation has helped me to understand the code.
Thank You!

Sree Kavitha

unread,
Nov 16, 2020, 1:08:12 PM11/16/20
to Discussion forum for Computational Thinking, lakshmis...@gmail.com, saisr...@gmail.com, Malabika Guha Mustafi, Discussion forum for Computational Thinking, AC
im a biology tudent , i really cant understand even ur discussions, pl help frnds

DHARMA TEJA GODUMALA

unread,
Nov 16, 2020, 1:52:31 PM11/16/20
to Discussion forum for Computational Thinking, DHARMA TEJA GODUMALA, pallavi...@gmail.com, Discussion forum for Computational Thinking, Adnan Jamil, krish...@gmail.com

Sorry a small correction from my side
In the above If is Not a loop ,
I frequently mentioned it as loop which is wrong,
if is a condition statement please correct my wording mentioned above. Remaining is fine.

On Friday, November 13, 2020 at 11:42:45 AM UTC+5:30 DHARMA TEJA GODUMALA wrote:

ayeshag...@gmail.com

unread,
Nov 16, 2020, 5:07:58 PM11/16/20
to Discussion forum for Computational Thinking, krish...@gmail.com, Adnan Jamil
@krish can you please explain this concept using an example
thank you

Message has been deleted
Message has been deleted
Message has been deleted

Malabika Guha Mustafi

unread,
Nov 17, 2020, 3:29:52 AM11/17/20
to Discussion forum for Computational Thinking, ayeshag...@gmail.com, krish...@gmail.com, Adnan Jamil
@ Sree,
Many people like me have non IT background. The syllabus is only covered very basic things.
Don't worry, you can easily pass the exam if some basics are clear.
1. Whenever there is a if condition, first check the braces. Where it is started and where it is ended. It will give you clear idea that which activities are under the if or condition.
That means, if the conditions stated are true then the activities within the braces will  be executed otherwise NO.

2. Check the condition itself.
It may be single ( like parts of speech == noun) 
Or multiple ( like  parts of speech== pronoun and P, where p is a variable)
If it is multiple then check the logic operator ( the operation is AND or OR between the conditions).

 If it is AND then all the conditions should be true(individually).[ for example, parts of speech== pronoun and P here both the conditions should be true  to execute the loop].
If it is OR  then if any one of the condition is true , then the if statement will be executed. ( it may be happend that all conditions or more than one condition are true).

Maximum questions are covered this part only, Hope, it helps you. All the best.

Reply all
Reply to author
Forward
0 new messages