Question: Help, I just cannot figure out how to make this code print x cannot be divided by zero after i set the y intercept value

Help, I just cannot figure out how to make this code print "x cannot be divided by zero" after i set the y intercept value to 0 and i want the code to print "x cannot be divided by zero" everytime i put a zero for y value.

Here is my code below: (PYTHON)

x_intercept = float(input("Enter x: ")) y_intercept = float(input("Enter y: ")) operation_msg = input("Enter operation (plus, power, divide): ") add_formula = x_intercept + y_intercept add_final = float(add_formula) power_formula =(x_intercept ** y_intercept) power_final = float(power_formula) divide_formula = x_intercept / y_intercept divide_final = float(divide_formula)

divison_form = y_intercept if operation_msg == "divide": print("x divided by y is : ", divide_form) if divison_form == 0: print("does not work")

elif operation_msg == "plus": print("x plus y:", add_final)

elif operation_msg == "power": print("x to the power of y is", power_final)

else: print ("I don't recognize that operation.")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!