You are viewing a single comment's thread. Return to all comments →
I didn't understand why they suggested the used of abs function in the question, here's my solution:
import cmath import math valor = input() complejo = complex(valor) partes = None real = None coeficienteimaginario = None if(valor.find("+") > 0): partes = valor.split("+") real = float(partes[0]) coeficienteimaginario = float(partes[1].replace("j","")) elif(valor.startswith("-")): partes = valor.split("-") real = float("-"+partes[1]) coeficienteimaginario = float(partes[2].replace("j","")) else: partes = valor.split("-") real = float(partes[0]) coeficienteimaginario = float(partes[1].replace("j","")) r = math.sqrt(pow(real,2)+pow(coeficienteimaginario,2)) print(r) ph = cmath.phase(complejo) print(ph)
Seems like cookies are disabled on this browser, please enable them to open this website
Polar Coordinates
You are viewing a single comment's thread. Return to all comments →
I didn't understand why they suggested the used of abs function in the question, here's my solution: