Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions