Q. Write a python script that ask the user to enter a length in centimeters. If the user enters a negative length, the program should tell the user that the entry is invalid. otherwise, The program should convert the length to inches and print out the result. there are 2.54 centimeters in an inch.


You can understand by Watching video :-



Answer :-

a = int(input("Enter the length in centimeter = "))

if a < 0 :
  print("Invalid")
else :
  print("Length in inch = ",a/2.54)

Output :-

Enter the length in centimeter = -463
Invalid

>>> 

Enter the length in centimeter = 565
Length in inch =  222.44094488188975

>>> 

Enter the length in centimeter = 52
Length in inch =  20.47244094488189

>>>

6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post