Monday, June 3, 2019

Python Tutorial For Beginners : Section -1


Python Tutorial For Beginners: Section-1 Number ( Integer, Float, Complex, Boolean )



#Python Numbers variable
a=12

#print Variable as define format here define is an integer
print (a)
#output would be
#12

#print Variable as integer convert from define format he a=12 is integer hence will
print (int(a))
#output would be
#12

#print variable as float value from integer as denine
print (float(a))
#output would be
#12.0


#print variable as complex value from integer as denine
#https://docs.python.org/2/library/functions.html#complex

print (complex(a))
#output would be
#(12+0j)


#for float value change to inter will work like as below
b=12.12
print (int(b))
#output would be the integer value as
#12



# How do we find the variable type from definirion of variable
a=12
print (type(a))
#ouput would be
#<class 'int'>


a=12.1
print (type(a))
#ouput would be
#<class 'float'>

a=1+2J
print (type(a))
#ouput would be
#<class 'complex'>


a=True
print (type(a))
#ouput would be
#<class 'bool'>

No comments:

Post a Comment

Wireless Security Configuration: Protect Your Network Now!

Introduction: In today’s connected world, wireless networks are as common as smartphones, and they’re often the gateway to our personal, pr...