def printr(): print('how many rectangles would you like to print') count = l.getnum(True) for i in range(count): print("which rectangle would you like to print") t = l.getnum(False, 0, len(mem) - 1) mem[t].show()
def check(): print('\nthere are {0} rectangles\n'.format(len(mem))) running = True paramt = ["length", "height", "area", "parimiter"] options = ['LENGTH', 'HEIGHT', 'AREA', 'PARIMITER', 'ALL', 'INDEX', 'BACK'] menu = """what would you like to check (type exactly what is in the brackets) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# ({0[0]})----details of all rectangles with a spesific {1[0]} ({0[1]})----details of all rectangles with a spesific {1[1]} ({0[2]})------details of all rectangles with a spesific {1[2]} ({0[3]})-details of all rectangles with a spesific {1[3]} ({0[4]})-------gives back the details of all the rectangles ({0[5]})-----give the details of a single rectangle ({0[6]})------go back to main menu """.format(options, paramt) validate(options, menu) for y in range(len(paramt)): if choice == options[y]: print("what is the {0} you would like to search for".format( paramt[y])) inp = l.getnum(True) for x in mem: param = [x.length, x.height, x.area, x.parimiter] if param[y] == inp: data(x, mem) if choice == options[4]: for x in mem: data(x, mem) elif choice == options[5]: print("what rectangle would you like to search for") inp = l.getnum(False, 0, len(mem) - 1) data(mem[inp], mem) elif choice == options[6]: running = exit()
def create(): measurements = ['length', 'hight'] print('how many times do you want to create a rectangle') amount = l.getnum(True) x = len(mem) for i in range(amount): re = [] for mes in measurements: print('what is the {0} of rectangle {1}'.format(mes, x + i)) re.append(l.getnum(True)) rectangle = l.Rectangle(re[0], re[1]) mem.append(rectangle)
def delete(): conf = ["YES", "NO"] menu = """are you sure you would like to delete this rectangle (type exactly what is in the brackets) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# ({0[0]})--yes ({0[1]})---no """.format(conf) print("how many rectagles would you like to delete") count = l.getnum(True) i = 0 while i < count: print("which rectangle would you like to delete") t = l.getnum(False, 0, len(mem) - 1) data(mem[t], mem) usr = validate(conf, menu) if usr == conf[0]: mem.remove(mem[t]) i += 1 elif usr == conf[1]: print("please chose a different rectangle then")
################################## # # # # # # # # # # # #this is the times table creator# # # # # # # # # # # # # ################################## # # # # # # # # # # # import library as l ##defined vairiables## space=[" "," "," ",""] #creats the space additions to make all the numbers 4 characters long ##getting inputs and user friendly outputs## print("Welcome to the timestable generator.\nPlease input the 2 whole numbers bellow") print("the first number cannot be higher than 99") num1=l.getnum(1,99) #gets the ammount of rows print("the second number cannot be higher than 45") num2=l.getnum(1,45) #gets the amout of collums ##calculations and output## for i in range(1,num1+1): #repeats for every row num=[] #the list of the numbers in the current row for j in range(1,num2+1): #repeats every number in the current row x=str(i*j) #gets the number that would be in said possition of the times table for h in range(4): #checks for how long the number is if len(x)==h+1: #-----^ x=x+space[h] #adds amount of spaces depending on how long the number is num.append(x) #adds the number onto the end of the row num=str(num) #converts the entire row to a string ######################################################################################## #python is very good at string manipulation so thats why this next part is very usefull#
import library as l print("please input a whole number") print("\nyour binary number is:\n" + str(l.dectobin(l.getnum(False))))