Q:

how to covert integer to float in pyhton

# Python code to demonstrate Type conversion 
# using int(), float() 
  
# initializing string 
s = "10010"
  
# printing string converting to int base 2 
c = int(s,2) 
print ("After converting to integer base 2 : ", end="") 
print (c) 
  
# printing string converting to float 
e = float(s) 
print ("After converting to float : ", end="") 
print (e) 
1
a = 5
a = float(a) # int to float
0

Tags

New to Communities?

Join the community