Redefine the repr()
of the complex class, or set z=a+jb+c+jd;z.real if z.imag==0 elsez
.
z=1.23-0j
# If the imaginary part is 0, only the real part is displayed.
print(z.real if z.imag==0 elsez)
I edited this post based on @metropolis's comment and posted it as community wiki.I edited this post based on @metropolis's Comment and posted it as Community Wiki.
© 2023 OneMinuteCode. All rights reserved.