Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 15e9730

Browse files
polar-coordinates
1 parent c1ef9e8 commit 15e9730

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎Hackerrank-Python3/polar_coordinates.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Enter your code here. Read input from STDIN. Print output to STDOUT
2+
from cmath import phase
3+
import math
4+
s = complex(input())
5+
d = math.sqrt((s.real * s.real) + (s.imag * s.imag))
6+
print(d)
7+
print(phase(complex(s.real, s.imag)))
8+
9+
# Constraints
10+
11+
# Given number is a valid complex number
12+
13+
# Output Format
14+
15+
# Output two lines:
16+
# The first line should contain the value of r.
17+
# The second line should contain the value of phi.
18+
19+
# Sample Input
20+
21+
# 1+2j
22+
# Sample Output
23+
24+
# 2.23606797749979
25+
# 1.1071487177940904
26+
# Note: The output should be correct up to 3 decimal places.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /