python 3.4 code practice question 2

“Write a program to convert a fraction to a decimal. Have your program ask for the numerator first, then the denominator. Make sure to check if the denominator is zero. If it is, print out “Error - cannot divide by zero.”

Respuesta :

numerator = int(input("Enter a number: "))

denominator = int(input("Enter a number: "))

if denominator != 0:

   print(numerator/denominator)

else:

   print("Error - cannot divide by zero.")