Python

Numeric conversions and creation of complex number

  • We can able to convert from one numeric form to other numeric form.
  • The following are the different conversions
  • Integer to float conversion
  • Float to integer conversion
  • Integer to complex
  • Complex to integer

Integer to float conversion

Example

a=5

b= float(a)

print(b)

output:

5.0

Float to integer conversion

example

a=5.5

b= int(a)

print(b)

Output:  5

Integer to complex

Example:

a=5

b= complex(a)

print(b)

output:

(5+0j)

How to Create complex  number?

The following is the way to create a complex number.

a=5

b=6

c=complex(a,b)

print(c)

output:

(5+6j)

Boolean

  • In python Boolean represents true or false
  • The following example represents  how boolean type works
a=10

b=20

a<b

output: True

In python true is represented by 1 and false is represented by 0.

>>int (True)

Ans:1

>>Int(false)

Ans:0

Lakshmi Durga

Share
Published by
Lakshmi Durga

Recent Posts

Google Spam Update 2025: Impact, Recovery Guide & SpamBrain Explained

Google released a spam update on 26th of August 2025 and this is affecting a…

2 weeks ago

Google Experiments with Black Sitelink Colors instead of Blue

Google keeps on testing google search display all the time and this time we are…

1 year ago

What are Template Tags in WordPress? How to Use Template Tags

In wordpress if you are developing new or custom wordpress theme or wordpress plugin then…

2 years ago

Google Search Indexing Issues Started on 31st January to February 2024

If you are experiencing indexing issues of your website then you are not alone and…

2 years ago

Create QR Code for Pages & Post using Plugin in WordPress

On your wordpress website if you want to generate qr code for pages and posts…

2 years ago

Add Google Search Console HTML File Upload on WordPress

If you are trying to verify your WordPress website with google search console with html…

2 years ago