def sqrt(x):
    value = x**(1/2)
    return value
print(sqrt(sqrt(sqrt(sqrt(718723)))))
2.322924510195928
n = int(input())
l = int(input())
def multiplicationtable(x,limit):
    for i in range(1,limit+1):
        print(str(x)+"*"+str(i)+"="+str(x*i))
        
multiplicationtable(n,l)
4*1=4
4*2=8
4*3=12
4*4=16
4*5=20
4*6=24
4*7=28

HW

Problem 1

Procedural Abstraction This code contains three procedures

def takeinput(): # takes input from user
    li = []
    while True:
        i = input()
        li.append(i)
        if i.lower() == 'no': # break with 'no' string entered
            break
    return li
        
def cleanlist(mylist): # clean up the list, delete all non-number elements
    cleaned = []
    for i in mylist:
        if '.' in i: # if it might be a float
            try: # try/catch to attempt conversion from string to float
                cleaned.append(float(i))
            except:
                pass
        else: # if there's no '.' in the element
            try:
                cleaned.append(int(i))
            except:
                pass
    return cleaned

def takeavg(mylist): # calculate the average of the cleaned list with only numeric elements
    s = sum(mylist)
    ave = s/len(mylist)
    return ave

grades = takeinput()
cleangrades = cleanlist(grades)
avg_grade = takeavg(cleangrades)
print("You entered: ")
print(grades)
print("The grades after deleting non-number elements: ")
print(cleangrades)
print("The average grade is "+str(avg_grade))
You entered: 
['93', '05', '94', 'o', 'bob', 'hahaha', '82.3', '99.4', '104', 'no']
The grades after deleting non-number elements: 
[93, 5, 94, 82.3, 99.4, 104]
The average grade is 79.61666666666667

Problem 2 summing_machine

def summing_machine(first_number,second_number): # ridiculously long variable names
    return first_number+second_number
a = 7
b = 5
result = summing_machine(a,b)
print(result)
12