# Day 10
# __ _ ___ _ _
# /__\ ___| |_ _ _ _ __ _ __ / __\ _ _ __ ___| |_(_) ___ _ __ ___
# / \/// _ \ __| | | | '__| '_ \ / _\| | | | '_ \ / __| __| |/ _ \| '_ \/ __|
# / _ \ __/ |_| |_| | | | | | | / / | |_| | | | | (__| |_| | (_) | | | \__ \
# \/ \_/\___|\__|\__,_|_| |_| |_| \/ \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
# return functions
# make a function return a specfic value
# def func(x,y):
# answer = x*y
# return answer
# or
# def func(x, y):
# return (x*y)
# if you are returning it, it need to be to stored in a
# 1. variable or
# 2. print fuction (e.g. print(func(5, 6)))
# a void fuction returns nothing
# naming a fuction main will make it run as when the program starts
# Part 1
# _,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
print("1. Heron Formula")
def clac_are_heron(x, y, z):
s = (x+y+z)/2
area = (s*(s-x)*(s-y)*(s-z))**0.5
return area
while True:
try: # ask for variables to put into function
interger1 = int(input("give me a number: "))
interger2 = int(input("give me another number: "))
interger3 = int(input("give me another number: "))
break # since there is no if condition, the while loop is always running (true) and breaks if succesful
except ValueError:
print("gotte be a number")
print("the area of this triangle", clac_are_heron(interger1, interger2, interger3))
# Part 2
# _,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
# same question as the first but with different spcfics
# you really don't need to def a function to do this but the point is to make on with a return
print("\n2. compound interest")
def interest(a, b, c, d):
return (a*(1+(b/100)/c)**(c*d))
while True:
try: # ask for variables to put into function
principal_value = int(input("whats the principal value: "))
rate = int(input("whats the rate: "))
times_per_year = int(input("how many times per year: "))
years = int(input("for how many years: "))
break
except ValueError:
print("gotte be a number")
print("your interest is", interest(principal_value, rate, times_per_year, years))