5 || Learn Python Programming Tutorial Online Training by Durga Sir

5 || Learn Python Programming Tutorial Online Training by Durga Sir

Base conversions:

—---------------------

  1. bin() {to convert the value from any base to binary}

bin(15)

‘0b1111’

  1. oct() {you can convert any value from any base to octal }

oct(786)

‘0o175316’

  1. hex() {from any base to hexadecimal}

hex(10)

‘0xa’

 

Float data  type:

—------------------

  1. x = 20.3 



Complex data type:

—----------------------

 

a+bj

 

a = real part (a part should be anything)

b = imaginary part  (this part should be compulsory decimal)

 

j^2 = -1

 

For example,

x = 10+20j

type(x)

<class ‘ complex ‘>

 

“j should be compulsory after the b symbol”



>>>>a = 10+20j

>>>>b = 20+30j

>>>>a+b 

>>>>(30+50j)

 

Bool data type:

—-----------------

We use this datatype to represent boolean values.

 

What are the allowed values in boolean datatypes?

 >> True and False 

 

For example:

b = true 

type(b)

<class ‘ bool’>



a = 10 

b = 20 

c = a<b

Output: True




True + True => 2

True + False => 1

 

In python internally True is represented by 1 and False is represented by 0.



str:

—-

 

In python, any sequence of characters is considered as str.

 

s  =’‘himanshu’’ 

 

type(s)

<class ‘str’>



s =”""Himanshu

            Sharma”""

print(s)

{this is a multiline string}















What's Your Reaction?

like
0
dislike
0
love
0
funny
0
angry
0
sad
0
wow
0