#turnary operator- shortcut to make code cleaner
#condition_if_true if condition else condition_if_else
is_friend = False
can_message = "message allowed" if is_friend else "not allowed to message"
print(can_message)
#short circuting
is_friend = True
is_user = True
print(is_friend and is_user)
if is_friend or is_user:
print('best friends forever')
#logical operator
print(4 > 5)
print (4==5)
print (4==4)
print ('a' > 'A')
#not
print(not(True))
#EXERCISE LOGICAL OPERATORS
is_magician = True
is_expert = True
if is_expert and is_magician:
print("you are a master magician")
elif is_magician and not is_expert:
print("at least you are getting there")
elif not is_magician:
print("you need magic powers")
#loops
for item in 'dobby is king':
print(item)
for item in ( 1,2,3,4,5):
print(item)
for item in (1, 2, 3, 4, 5):
for x in ['a', 'b', 'c']:
print(item, x)
#iterable
user = {
'name': 'pepe',
"age" : 23,
'can_swim': False
}
for item in user:
print(item)
for item in user.values():
print(item)
for item in user.keys():
print(item)
#counter
my_list = [1,2,3,4,5,6,7,8,9,10]
counter = 0
for item in my_list:
counter = counter + item
print(counter)
#range()
for _ in range(0,10, 2):
print(_)
#enumerate()
for i,char in enumerate('curry '):
print(i,char)
for i,char in enumerate('bricked up'):
print(i,char)
#while loops- infinate loop to be wary off
for item in [1,2,3]:
print(item)
i = 0
while i <len([1,2,3]):
print(i)
i += 1