def a():
print('I am from function a')
return 1
x=a()+a()
print(x)
####
def a(x): #x=1
print('I am from function a',x)
return x
y=a(1)+a(2)
print(y)
####
def a(x): #x=[0],x=[2]
print('I am from function a',x[0])
return x
y=a([0])+a([2])
print(y)
####
def b():
print("I am from b")
def a(x): #x=b
print('I am from function a',x)
x() #becos we added this line, x must be a functoin
return 1
y=a(b)
print(y)
####
def b(y,z):
print("I am from b", y+z)
return y+z
def a(x,y,z): #x=b
print('I am from function a',x)
x(y,z) #becos we added this line, x must be a function
return x(y,z)
h=a(b,1,2)
print(h)
####
x=-10
if x>0:
print("x is larger than 10")
else:
print('x is less than 0')
x=x+1 #controller
####
x=-10
if print("i am in the if condition"): #after if, it is an expression, true or false only
print("x is larger than 0")
else:
print('x is less than 0')
x=x+1
####
x=-10
def a():
print("i am from function a")
return 1
if a():
print("x is larger than 0")
else:
print('x is less than 0')
x=x+1
####
x=0
def a(y):
print("i am from function a")
return y
if a(x):
print("x is larger than 0")
else:
print('x is less than 0')
x=x+1
####
x=90
if x>=90:
print("you got A")
elif x>80:
print('you got B')
elif x>70:
print('you got C')
else:
print("D or below")
####
x=10
while x>0:
print ("x is now", x)
x=x-1
if x==5:
break
else:
print("loop complete without break")
####
x=8
while x>0:
if x==6: #start from 8, skip 6
x=x-1
continue
print("x is now",x)
x=x-1
if x==3:
break
else:
print("loop complete without break")
####
x=1,2,3,4,5
for i in x:
print(i**2) #square the i
else: #after all for actions, it will go to else action
print ("for loop completed")
####
x=1,2,3,4,5
for i in x:
if i==1:
continue
if i==3:
break
print(i**2)
else:
print ("for loop completed")
####
x="12345" #this is a str.
for i in x:
i=int(i) #change it into int. to run
if i==1:
continue
if i==3:
break
print(i**3)
else:
print ("for loop completed")