Program to convert polar co | Python 3 program for the above approach ; Function to convert degree to radian ; Function to convert the polar coordinate to cartesian ; Convert degerees to radian ; Applying the formula : x = rcos ( theata ) , y = rsin ( theta ) ; Print cartesian coordinates ; Driver Code ; Given polar coordinates ; Function to convert polar coordinates to equivalent cartesian coordinates
import math NEW_LINE def ConvertDegToRad ( degree ) : NEW_LINE INDENT pi = 3.14159 NEW_LINE return ( degree * ( pi / 180.0 ) ) NEW_LINE DEDENT def ConvertToCartesian ( polar ) : NEW_LINE INDENT polar [ 1 ] = ConvertDegToRad ( polar [ 1 ] ) NEW_LINE cartesian = [ polar [ 0 ] * math . cos ( polar [ 1 ] ) , polar [ 0 ] * math . sin ( polar [ 1 ] ) ] NEW_LINE print ( ' % .3f ' % cartesian [ 0 ] , ' % .3f ' % cartesian [ 1 ] ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT polar = [ 1.4142 , 45 ] NEW_LINE ConvertToCartesian ( polar ) NEW_LINE DEDENT