cmath

cmath

cmath.phase

This tool returns the phase of complex number z (also known as the argument of z).

>>>phase(complex(-1.0, 0.0))
3.1415926535897931

## cmath.abs
This tool returns the modulus (absolute value) of complex number z.

You are given a complex . Your task is to convert it to polar coordinates.

My solution


Adapted solution

code

cmath.polar()

Task
You are given a complex number z . Your task is to convert it to polar coordinates.
Input Format
A single line containing the complex number z. Note: complex() function can be used in python to convert the input as a complex number.
Constraints
Given number is a valid complex number
Output Format
Output two lines:
The first line should contain the value of .
The second line should contain the value of .

My solution

import cmath
print(*cmath.polar(complex(input())), sep='\n')

Adapted solution

code

You'll only receive email when understanding publishes a new post

More from understanding