19 % 4 != 300 / 10 / 10 is True


#1

For Conditional and Control Flows

My question: Why is 19 % 4 != 300 / 10 / 10 True?

My Math: 19 % 4 means that 19 divided by 4 leaves 3. And 300 divided by 10 divided by 10 equals 3
Therefore 3 = 3

The statement is 3 != 3 is true

My answer is False

My reasoning: 3 is equal to 3 but the answer says that 3 is not equal to 3

Where am I going wrong?


#2

I tried it out with:

print 19 % 4 != 300 / 10 / 10

This prints False to the console for me.

I assume you are stuck at "And". I set bool_three equal to False and the answer is accepted.


#3

Hi eveat, I am seeing that the answer is true in the editor. I entered the following into line 5:
bool_three = True and False and it gives the green check mark with the "good to go" green messaging.

Due to your response, I decided to enter False and False to see if I would pass and I did (surprisingly). ie. I got the same green messaging.

Should I be entering my answers differently? Below I am cut/pasting all of my answers for reference:

bool_one = False and False is False

bool_two = True and False

bool_three = True and False

bool_four = True and True

bool_five = True and True is True


#4

I think you are supposed to put in just True or just False.

Your solution still works, because python evaluates True and False to False. It also does that for False and False and also for False and True. Only True and True evalates to True.

Try to set all variables directly to one value, e.g. :

bool_one = False

And don't use is anywhere, it's a python operator that to my knowledge isn't covered in the python course.


#5

I'm not sure if this matters anymore but I did the math for that one and I read the problem "19 % 4! = 300/10/10" as 19 percent of 4! = 300/10/10.

4! is 24, and 19 percent of 24 is 4.56

I think because you read the 19% 4 as 19 divided by 4, rather than 19 percent of 4, that's where you went wrong when you did the math the first time.

I hope this helps you or anyone else looking at this.


#6

19 % 4 is 3. The modulo operator % gives you the remainder of deviding the left number by the right number.

In Python ! does not stand for faculty, != is a comparison that checks if two expression are unequal.

print 4 != 2
# prints True because 4 does not equal 2

a != b is equivalent to

not (a == b)


#7

i only writted True or False:
bool_one = False

bool_two = False

bool_three = False

bool_four = True

bool_five = True

So...
19 % 4 != 300 / 10 / 10 and False
3 != 3 and False
True and False
False (because The boolean operator and returns True when the expressions on both sides of and are true)


#8

your percent of argument is not valid. eveat is correct about the modulo operator.

let's take -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2 and break it down with your percent of theory...

-1 < 1 and 1 <= 20 - 100
True and 1 <= -80
True and False
False

Yet, if you put that in the lab, it comes out True.


#9

You're right. I had completely forgotten that's what the modulo was. I assumed it was right since it had worked for me. Thanks for clearing this up guys, looks like I've got some more studying to do!


#10

Sorry, super late to the party here. I'm stuck more on the modulo than anything else.
I don't really understand how 19%4 gives three.

My understanding is that 19%4 should return the remainder of dividing 19 by 4.
19/4 = 4.75
So, 4 goes into 19 4 times with a remainder of 0.75.
At this point, I'm stuck because I don't know how 0.75 remainder correlates to a value of three. Is it because 0.75*4 is 3?

I guess talking through made it make sense to me. I tried the above logic with 1%3, 2%3, 3%3 and it seemed to work.

Please let me know if my understanding is flawed.
Thanks


#11

If you divide 19 by 4, you get 4, with 3 left over. 19 = (4 * 4) + 3. You have 3 remainder.


#12

Can anyone guess why this exercise is made out of so complicated calculation and not just numbers between -10 and 10?


#13

The person who made it got creative? idk


#14

False is correct for 19 % 4 != 300 / 10 / 10, but what they are asking is what does False and False equal. The "and" checks if both values are True, which they are not, so it returns False.


#15

Guys I understand the logic but why I m not able to proceed?

for 19 % 4 != 300 / 10 / 10
bool_three = 3!= 3 and -10>2 (19 Modulo 3 is 3 and 300/10/10 is 3)

I get the following error :

File "python", line 5
bool_three = 3!= 3 and -10>2
         ^

SyntaxError: invalid syntax


#17