- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we unpack a string of integers to complex numbers in Python?
A string contains two integers separated by comma. It is first split in a list of two strings having digits.
>>> s="1,2".split(",") >>> s ['1', '2']
Two items are then converted to integers and used as arguments for complex() function
>>> complex(int(s), int(s)) (1+2j)
This results in unpacking of string of integers in a complex number
- How can we use complex numbers in Python?
- How can we read inputs as integers in Python?
- How to Plot Complex Numbers in Python?
- How to find Square root of complex numbers in Python?
- Complex Numbers in Python?
- How can we generate Strong numbers in Python?
- How can I eliminate numbers in a string in Python?
- How can we get substring from a string in Python?
- How can we convert a list of characters into a string in Python?
- How to unpack using star expression in Python?
- How do we check in Python whether a string contains only numbers?
- How we can break a string with multiple delimiters in Python?
- How does modulus work with complex numbers in Python?
- How can we extract the numbers from an input string in Java?
- Python program for Complex Numbers