Computer Science, asked by mohdzafarkhan21, 3 days ago

b. Write a python program to convert centimeters to inches. Hint: 1 inch = 2.54 cms ​

Answers

Answered by samarthkrv
31

Answer:

centi = float(input("Enter the length in centimetres:"))

inch = centi / 2.54

print(centi , " cm in inches is " , inch)

Explanation:

Answered by nupursophia
16

Answer:

centi = float(input("Enter the length in centimetres:"))

inch = centi / 2.54

print(centi , " cm in inches is " , inch)

Explanation:

# Get input from user

cm = float(input("Enter a value in centimeters: "))

# Convert centimeters to inches

inches = cm / 2.54

# Print the result

print(f"{cm} centimeters is equal to {inches} inches.")

This program uses the input() function to get a value in centimeters from the user, which is then stored in the variable "cm". The program then divides the value in "cm" by 2.54 to convert it to inches, and assigns the result to the variable "inches". The program then uses the print() function and string formatting to output the result to the user.

This is a simple program that calculates the conversion of cm to inches. You could also use function definition to make it more reusable and maintainable.

To know about variables, click on the link below:

brainly.in/question/9067360

To know about formatting, click on the link below:

https://brainly.in/question/33285632

#SPJ3

Similar questions