# Functions
# ___ _ _
# / __\ _ _ __ ___| |_(_) ___ _ __ ___
# / _\| | | | '_ \ / __| __| |/ _ \| '_ \/ __|
# / / | |_| | | | | (__| |_| | (_) | | | \__ \
# \/ \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
# you can put your code into Functions to organize
# they have to be declared first (like a variable)
# def function_name(parameters):
# Part 1
# _,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,__,.-'~'-.,_
print("1. monthly multiplier")
def output_month(x): # checks every month and outputs the corespoding one | trail and error
if x == 1:
print("the month is january")
elif x == 2:
print("the month is febuaray")
elif x == 3:
print("the month is march")
elif x == 4:
print("the month is april")
elif x == 5:
print("the month is may ")
elif x == 6:
print("the month is june")
elif x == 7:
print("the month is july")
elif x == 8:
print("the month is august")
elif x == 9:
print("the month is september")
elif x == 10:
print("the month is october")
elif x == 11:
print("the month is novemeber")
elif x == 12:
print("the month is december")
month = 0
while month < 1 or month > 12: # standerd error checking input
try:
month = int(input("give me an interget between 1 and 12: "))
if month < 1 or month > 12:
print("gotta fit the range")
except ValueError:
print("gotta be a number")
output_month(month)
# Part 2
#.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
print("\n\n2. sunm it up!")
def sum_it_up(x, y): # checks if x > y and vice versa to make inputs easir
global sums # set global to be used outside the fuction
if x > y:
for i in range(y, x+1):
sums = sums + y
y+=1
elif y > x:
for i in range(x, y+1):
sums = sums + x
x+=1
else:
sums = x + y
print(sums)
interger1 = interger2 = sums = 0
while True:
try:
interger1 = int(input("give me a number: "))
interger2 = 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")
sum_it_up(interger1, interger2)
# Part 3
#.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:.
print("\n\n3. simple intrest rate")
def calc_simple_interest(x, y, z):
I = x*y*z
# use f-string for easier syntax
print(f"the interest on a principal of ${x} at a rate of {y} for {z} years is {I}")
calc_simple_interest(1000, 0.05, 10)