// Number as string
number = 12
number_as_string = str(number)
Functions
// Defining a function
def function_name(text):
print("Function received this text: " + text)
def power_function(base, exp):
return base**exp
def manual_power(base, exp):
result = 1
for i in range(x):
result = result * num
return result
def add_all(*args):
result = 0
for x in args:
result = result + x
return result
Conditionals
x, y = 10, 12
if (x < y):
print("X<Y, or {}<{}".format(x,y))
elif (x > y):
print("X<Y, or {}<{}".format(x,y))
else:
print("X and Y are the same: {}".format(x))
Loops
Classes