Generation

generate functionTue, 02 May 2023

programa que pida al usuario ingresar una función y muestre en pantalla el dominio e imagen de dicha función

def getFunction() : function = input("Ingrese una funcion: ") return function f = getFunction() f = "((x**2) + 2*x)/(x**2 + 1)" def getDomain(f): domain = [] for i in range(10): x = float(i) try: #evaluar la función en el punto x y = eval(f.replace("x", str(x))) except ZeroDivisionError: if i == 0: continue domain.append(x) return domain def getImage(f): image = [] for i in range(10): x = float(i) try: #evaluar la función en el punto x y = eval(f.replace("x", str(x))) except ZeroDivisionError: if i == 0: continue image.append(y) return image print

Questions about programming?Chat with your personal AI assistant