This code works fine in python 2, but the input function was changed between python 2 and python 3 in compliance with PEP 3111:
- What was
raw_input in python 2 is now called just input in python 3.
- What was
input(x) in python 2 is equivalent to eval(input(x)) in python 3.
This is how it always should have been, as calling eval on user input is unsafe and unintuitive, certainly shouldn't be the default for user input, and is still easy to do if that's what you really want.
Taking your code example as a toy example, you can make it work by replacing
r = float(input("Enter the radius: "))
angle = float(input("Enter the angle: "))
with
r = float(eval(input("Enter the radius: ")))
angle = float(eval(input("Enter the angle: ")))
but you DO NOT want to do that in real-world code. Instead, you would want to use one of the solutions suggested in this question: Equation parsing in Python.