X Tutup
Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 1.36 KB

File metadata and controls

34 lines (29 loc) · 1.36 KB
title Python complex() built-in function - Python Cheatsheet
description Return a complex number with the value real + imag*1j or convert a string or number to a complex number. [...] Each argument may be any numeric type (including complex). If imag is omitted, it defaults to zero and the constructor serves as a numeric conversion like int and float. If both arguments are omitted, returns 0j.
Python complex() built-in function From the Python 3 documentation Return a complex number with the value real + imag*1j or convert a string or number to a complex number. [...] Each argument may be any numeric type (including complex). If imag is omitted, it defaults to zero and the constructor serves as a numeric conversion like int and float. If both arguments are omitted, returns 0j.

Examples

>>> complex(1)
# (1+0j)
>>> complex('1')
# (1+0j)
>>> complex(100)
# (100+0j)
>>> complex('100')
# (100+0j)
X Tutup