And & Or


#1

Im completly new to code and I have some problems with And & Or.
Sorry if Im abit hopeless but Im grateful for all help!
Thank you!

With And I passed but I dont really know why, I do get it with the False or True but howcome that example bool_four dont need "is true" while bool_one need to have "is False" written?

bool_one = 1 > 2 and 2 > 3 is False

bool_two = -(-(-(2))) == -2 and 4 >=16**0.5 is True

bool_three = 19%4 != 300 / 10 / 10 is False

bool_four = -(1**2)<2**0 and 10 % 10 <= 20 - 10*2

bool_five = 10/10 == 1/1

On the "Or" Im stuck completly, I really have no idea if Im doing it right, thought it would be similar to And but I would be very happy if someone would help me.

bool_one = 2**3 == 108%100 or 'Cleese' == 'King Arthur'

bool_two = 1<2 or 2>4 is True

bool_three = 100**0.5 >= 50 or 1+3 == 4+5

bool_four = 2>1 or 3>1

Bool_five = 1**100 == 100**1 or 3*2*1 != 3+2+1


#2

Maybe this might help
There is a thing called a truth table. It's used for Boolean expressions and for digital electronics

1 AND 1 = 1
1 AND 0 = 0
0 AND 0 = 0

TRUE AND TRUE = TRUE
TRUE AND FALSE = FALSE
FALSE AND FALSE = FALSE

1 OR 1 = 1
1 OR 0 = 1
0 OR 0 = 0

You can do the substitution for the TRUE , FALSE part yourself.
The reason OR works the way it does is sometimes easier to fathom if you think how digital electronic circuits work.
We think of these circuits as electronic gates.
So you have a gatekeeper called OR
Does that help to make sense of what OR should do ?


#3

Thank you so much for explaining!
I got it to work! Seems like I had a capital letter where I shouldnt have one.
Tho, trying out some things, ex. writing is True/False or leaving it empty seems to work both either way, sorry for the beginner question, just abit confused since the excercise was to write either True/False.

Sorry for my bad english, hope you understand me.


#4

Yep, there are variations in the syntax of true and false in various computer languages. That's just technical. With more use and practice you get to know the differences. Or just reference it on the WWW.
If you're referring to leaving one side of an OR or AND combination empty, and if I understand you correctly, do not do that. That's bad logic flow. You need to have the comparision completed on both sides. Otherwise it will catch you out when you start writing actual script files.
About your english ? I did'nt see any problem with your writing. And we were all beginnners at one time.


#5

I cant thank you enough dondabrera!
Thank you for making my learning into programming easier and more fun :smile:


#6

Set bool_three equal to the result of 100**0.5 >= 50 or False

10 >= 50 or False

I come up with bool_three = False or False is False , But the response is "Double check your value for bool_three"

What am I doing wrong?


#7

You are comparing at the very base, sqrt(100) >= 50 or False(==0).

Bools are 0 or 1 values False happens to be 0.

So in essence you are asking 10>=(50 or 0)

If you want it to be compared to False you need to do it as follows,

(100**0.5 >= 50) or False

#8

But False or False is False

I'm missing something...


#9

I just got it!! I confused myself with my answers!! Thanks!!


#10

why bool_two is true ?
I guess it should be like this
4 negative sign for 2 would be a positive and its not equal to -2 and 4>=16**0.5 is true so it is
False and True and its False


#11

I have attempted to type Bool_Three for this problem every way that I can, but it keeps saying check the value


#12

I'm not sure if there was some kind of glitch. But these were the answers that yielded a completion status for the lesson 7 (OR statements).
bool_one = True or False is True
bool_two = True or False is False (?)
bool_three = False or False is True (?)
bool_four = True or True is True
bool_five = False or False is True (?)