Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.

Have an account? Sign In

Captcha Click on image to update the captcha.

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Tech Answered Logo Tech Answered Logo
Sign InSign Up

Tech Answered

Tech Answered Navigation

  • Home
  • Tutorials
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us
Home / Questions /Q 3097
Next
In Process
sita
sita

sita

  • India
  • 105 Questions
  • 59 Answers
  • 1 Best Answer
  • 74 Points
View Profile
  • 0
sita
Asked: September 22, 20212021-09-22T20:08:19+05:30 2021-09-22T20:08:19+05:30In: Python

how to print complex numbers in python with example program

  • 0

I got a assignment to print complex numbers in python. First of all what complex numbers? And how to do programming in python to print complex numbers with example program and output too.

I am very basic learner in python. so would you please consider my request to explain this complex number problems in detail for me. Thanks in advance 😀😀😀.

how to print complex numbers in pythonhow to print complex numbers in python 2021how to print complex numbers in python 2022how to print complex numbers in python with examplehow to print complex numbers in python with example outputpython programming .
  • 2
  • 1,649
  • 0
  • 0
Answer
Share
  • Facebook

    Related Questions

    • Python Program To Print Stars (*) In Different Patterns?
    • Write A Python Program To Accept A File Name From The User And Print The Extension Of The File Name.
    • Addition of two numbers in Python using user input example program
    • python error a bytes-like object is required
    • How to reverse list elements in python with example
    • Python error api-ms-win-crt-runtime-l1-1-0.dll is missing
    • in python what is method inside class ?

    2 Answers

    1. Vaishnavi262

      Vaishnavi262

      • India
      • 2 Questions
      • 2 Answers
      • 0 Best Answers
      • 27 Points
      View Profile
      Vaishnavi262
      2021-09-25T14:58:53+05:30Added an answer on September 25, 2021 at 2:58 pm
      This answer was edited.

      To print complex numbers in python language, the logic is pretty simple and I’m writing a example program to print complex numbers in python below. First of all we see what is complex number

      So, A complex number is a number which is in the form of :-

      x+iy

      Where x and y are real numbers

      Python is a interpreted high level general purpose programming language with dynamic semantics.

      So, In python we can convert two real numbers into a complex number using the complex function

      z=complex (x,y);

      to use this function we have to import cmath library, to access the real value of a complex number we can write z.real

      And to access it’s imaginary part we can write z.img

      #x + iy

      import cmath

      #Initializing real numbers

      x = 3

      y = 5

      # converting x and y into complex number z = complex(x,y);

      print(z)

      #printing real and imaginary part of complex number

      print (“The real part of complex number is : “)

      print (z.real)

      print (“The imaginary part of complex number is : “)

      print(z.imag)

      Let’s run this code

      Output:-

      (3+5j)

      The real part of complex number is : 3.0

      The imaginary part of complex number is : 5.0

       

       

      how to print complex numbers in python with example program
      • 1
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. Vaishnavi262

      Vaishnavi262

      • India
      • 2 Questions
      • 2 Answers
      • 0 Best Answers
      • 27 Points
      View Profile
      Vaishnavi262
      2021-09-25T20:49:27+05:30Added an answer on September 25, 2021 at 8:49 pm

      First of all we see what is complex number

      So, A complex number is a number which is in the form of :-

      x+iy

      Where x and y are real numbers

      Python is a interpreted high level general purpose programming language with dynamic semantics.

      So, In python we can convert two real numbers into a complex number using the complex function

      z=complex (x,y);

      to use this function we have to import cmath library, to access the real value of a complex number we can write z.real

      And to access it’s imaginary part we can write z.img

      #x + iy

      import cmath

      #Initializing real numbers

      x = 3

      y = 5

      # converting x and y into complex number z = complex(x,y);

      print(z)

      #printing real and imaginary part of complex number

      print (“The real part of complex number is : “)

      print (z.real)

      print (“The imaginary part of complex number is : “)

      print(z.imag)

      Let’s run this code

      Output:-

      (3+5j)

      The real part of complex number is : 3.0

      The imaginary part of complex number is : 5.0

      • 1
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    More Questions

    • Himasree

      What is the difference between modules and packages in Python?

    • Swathi

      how to remove indentation error in python

    • Swathi

      what is the difference between list and tuple in python

    • Vipinkv

      Python Program To Print Stars (*) In Different Patterns?

    • Vipinkv

      What Is The Python Program To Print The Calendar Of

    • Krishna Vijayan

      Write A Python Program To Accept A File Name From

    • Vipinkv

      Python Program To Count The Number Of Vowels In A

    • arunraj503

      Addition of two numbers in Python using user input example

    Stats

    • Questions 1,992
    • Answers 2,102
    • Posts 12
    • Best Answers 73

    Related Questions

    • Vipinkv

      Python Program To Print Stars (*) In Different Patterns?

    • Krishna Vijayan

      Write A Python Program To Accept A File Name From The User

    • arunraj503

      Addition of two numbers in Python using user input example program

    • Aniya

      python error a bytes-like object is required

    • shree

      How to reverse list elements in python with example

    • Hardik

      Python error api-ms-win-crt-runtime-l1-1-0.dll is missing

    • alex digi

      in python what is method inside class ?

    Explore

    • Home
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help

    Footer

    Recent Comments

    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • muller on how to solve export problem in kinemaster
    • AaronBlackburn on why can’t i find my message requests on instagram
    • shree on How to use philips citrus press juicer 25 watts Demo
    Ask A Question

    Archives

    Tags

    laptop buying guide (1) limit google news notifications (1) printer buying guide (1) stop google news notifications (1) turn off google news notifications (1)

    Social media

    © 2023 @ Techanswered.com.
    Terms, Privacy policy & Sitemap.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.