Sunday, July 7, 2019

Converting inch to centimetre using Functions

Script

#!/usr/local/bin/python3.5

def mathematics():
  print("Mathematics is fun!!!")

def inch_to_centimetre(inch):
  cm = inch * 2.54
  print(cm)


mathematics()

inch_to_centimetre(1)
inch_to_centimetre(5)
inch_to_centimetre(12)
inch_to_centimetre(20)
inch_to_centimetre(72)
inch_to_centimetre(100)

Execution

Mathematics is fun!!!
2.54
12.7
30.48
50.8
182.88
254.0




No comments:

Post a Comment