MOCK TEST , Qs. 7

113 views
Skip to first unread message

Ranjit John

unread,
Nov 13, 2020, 1:26:13 PM11/13/20
to Discussion forum for Computational Thinking, mailtores...@gmail.com
Answer key for Qs. 7 is last option which says
IF ( (A and B) = = FALSE and (A or B) = = TRUE {
                            - - - - - - - - - - - - -- - - - - - -- - - - -- - - 
}

Dont understand the logic asking  BOTH A & B to be FALSE (ie., A should be False and B should be False) and Any of it (A or B) to be True. 

How is it possible  to execute the code where first part ask to ensure both variables should be FALSE and other part asking to ensure any of it to be TRUE ??

It should be If (A == True and B==False) or (A==False and B==True){
                           return (True)
                       }

Please help to understand the answer key.

Since other options donot match at all, i selected last option without checking it and it turned out to be correct. But still confusion remain as it is. 

With regards,
Ranjit John

Anand Iyer

unread,
Nov 14, 2020, 5:24:13 AM11/14/20
to Discussion forum for Computational Thinking, ranjitj...@gmail.com, mailtores...@gmail.com
Ranjit,

this is a usage that I'm not sure has been dealt with within the course lectures.  But, the usage is valid.

if A == True can be written as if A.  Similarly if B == True can be written as if B.

Thus, the statement if (A and B) == False is interpreted as if ((A == True) and (B == True)) == False

and, the statement if (A or B) == True is interpreted as if ((A == True) or (B == True)) == True
 
Now, look at the attached picture, you should get an idea...

I'm hoping this will clarify your question...
Capture.JPG

Reshmi Ranjit

unread,
Nov 14, 2020, 5:26:09 AM11/14/20
to Anand Iyer, Discussion forum for Computational Thinking, ranjitj...@gmail.com
Thank you Very much for the clarification. 

Ranjit John

unread,
Nov 14, 2020, 1:29:35 PM11/14/20
to Anand Iyer, Discussion forum for Computational Thinking
Thanks a lot Anand.
With regards,
Ranjit John

On Sat, 14 Nov 2020, 15:54 Anand Iyer, <anandd...@gmail.com> wrote:

Brajesh Kedia

unread,
Nov 16, 2020, 2:53:52 PM11/16/20
to Discussion forum for Computational Thinking, Ranjit John, Discussion forum for Computational Thinking, anandd...@gmail.com
I find the image for what we can also say "Truth Table" by Anand is wrong... (Check A and B table)

The idea of A and B CONJUNCTION operator is purely based on logic that both have to be true for result to be true.   (Any one false then whole result is false)

The idea of A OR B DISJUNCTION operator is stating the logic, I am fine with any one being true, if both too, i am fine i.e., true..   (If both false that's False as result)

Conclusion - Since, We want Same year or Same Genre but not both hence we are saying we want either A and B = false ,AND, either A or B be True But if A or B be True means A and B is also True but we don't want that...

Understanding THIS last line AGAIN... IN TERMS OF VENN DIAGRAM... We want the common A and B be removed and A and B seperately so we want A and B = false and A or B = true

Point to note - between both conjunction and disjunction operator there is AND than it's fine otherwise we shall conclude in hanging way and get A and B common too.

rahul agarwalla

unread,
Nov 16, 2020, 6:03:29 PM11/16/20
to Discussion forum for Computational Thinking, brajesh...@gmail.com, Ranjit John, Discussion forum for Computational Thinking, anandd...@gmail.com
How about considering it binary way:

True=1, False = 0

A and B = A X B, in that case if any one of them is false the result will be FALSE and condition A and B == FALSE will become true.
Parallely A or B = A + B, in that case if any one is true result will be true and the condition A or B == TRUE will be become true

For example A = TRUE (1) and B = TRUE ( 1) ==> A X B =1 and condition that A and B ==FALSE will be BECOME false.
                       A = FALSE (0) and B = TRUE (1) ==> A X B = 0 and condition that A and B == FALSE will become TRUW.

So if condiiton if "  IF ( (A and B) = = FALSE and (A or B) = = TRUE )" ===> If (TRUE AND TRUE) which allow the further opertion inside the loop.

If my understanding is more correct.

Anand Iyer

unread,
Nov 16, 2020, 8:42:21 PM11/16/20
to Brajesh Kedia, Discussion forum for Computational Thinking, Ranjit John
@Brajesh,

I guess you didn't try to understand the problem fully, and my answer.  

Read it again.  It's not a truth table for A and B, it's a truth table for (A and B) is False


--
Cheers,
Reply all
Reply to author
Forward
0 new messages