Write a Python program to convert true to 1 and false to 0


Introduction

Write a Python program to convert true to 1 and false to 0. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. x = 'true'
  2. x = int(x == 'true')
  3. print(x)
  4. x = 'xyz'
  5. x = int(x == 'true')
  6. print(x)
  7.  

Result

python language techstudy.org

     





Related Topics




Popular Posts