304 North Cardinal St.
Dorchester Center, MA 02124
You are given a complex z. Your task is to convert it to polar coordinates.
A single line containing the complex number z. Note: complex() function can be used in python to convert the input as a complex number.
Given number is a valid complex number.
Output two lines:
The first line should contain the value of r.
The second line should contain the value of q.
Note: The output should be correct up to 3 decimal places.
from math import atan2 z = complex(input()) x,y = z.real, z.imag r = (x**2+y**2)**.5 phi = atan2(y,x) print r print phi
# Enter your code here. Read input from STDIN. Print output to STDOUT import cmath print(*cmath.polar(complex(input())), sep='\n')
# Enter your code here. Read input from STDIN. Print output to STDOUT from cmath import phase inp = raw_input() print round(abs(complex(inp)),3) print round(phase(complex(inp)),3)
import cmath c = complex(input()) print(abs(c)) print(cmath.phase(c))
In our experience, we suggest you solve this Polar Coordinates Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Polar Coordinates problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Polar Coordinates Hacker Rank Solution
I hope this Polar Coordinates Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning Programming in a business context; there are no prerequisites.
More Hacker Rank Problem & Solutions >>
Staircase Hacker Rank Solution
A Very Big Sum Hacker Rank Solution
Diagonal Difference Hacker Rank Solution
Nested Lists Hacker Rank Solution