You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# A psuedo code exampleifsomeconditionistrue:
dothiselifSomeotherconditionistrue:
Dothiselse:
dosomethingelse
# A real example of Conditonalsifx==5:
print('Five')
elifx==6:
print('Six')
else:
print('Nothing is valid')
Falsiness and Truthiness
This really matter
Empty strings, None , 0 has a false value
Everything else has true value
x=input('Whats your favorite TV Show')
ifx:
print('Wow I like that too !')
else:
print('You have entered nothing')
# This is an example of the truthiness and falsiness # if user enters nothing it will print out nothing
Comparison Operators
Op
What it does
Example
==
Truthy if a has the same value as b
a == b # True
!=
Truthy if a does NOT have the same value as b
a != b # False
>
Truthy if a is greater than b
a > b # False
<
Truthy if a is less than be b
a < b # False
>=
Truthy if a is greater than or equal to b
a >= b # True
<=
Truthy if a is less than or equal to b
a <= b # True
Logical Operators
Operator
What it does
And
Both values have to be true in order to be true
Or
If one of the value is true then the entire thing is true
Not
Its is like negation
state=input('Enter the state where you live')
ifstate=='NJ'orstate=='NY':
print('You live close to East Coast')
else:
print('You live far away from the coast')
# In this one of them has to be true
#Not operator Exampleage=10notage<5# This will be true
is vs ==
is and == operators are not the same
is operator compares two things and checks if they are stored at the same location in the memory