
#Expression
print(5 + 10)

# Definition/Variable assignment
LBS_TO_KILO = 0.45359237
print(175 * LBS_TO_KILO)

# Variable re-assignment (mutation)
age = 19
print(age)
age = age + 1
print(age)

# Selection (conditional)
JOE_AGE = 25
if JOE_AGE < 18:
  print("minor")
elif JOE_AGE < 65:
  print("adult")
else:
  print("senior")

# Function
def celsius_to_fahrenheit(cdeg):
  return 32.0 + (cdeg * 1.8)
print(celsius_to_fahrenheit(25.0))

celsius_to_fahrenheit(25.0)

# Repetition(definite/fixed iteration loop)
# Definite FOR loop with mutation
total = 0
for x in range(10):
    total = total + x
print(total)

# Repetition (indefinite/conditional loop)
# "WHILE" conditional loop
import random
guess = 1
while guess % 7 != 0:
    guess = random.randint(0, 99)
print(guess)

# Repetition (recursive function, performs root find 
# midpoint algorithm on exponential functions)
def root(n, start, end, base):
    if end <= start:
        return int(start)
    else:
        mid = int((end + start) / 2)
        guess = mid ** base
        if guess < n:
            return root(n, mid + 1, end, base)
        elif guess > n:
            return root(n, start, mid, base)
        else:
            return mid
print(root(16, 0, 16, 2))
print(root(24, 0, 24, 2))


