Skip to main content

Convert Centimeters to Inches Python Programming | Python Program Conver...

YouTube Video Tutorial How to write a Python program to convert centimetres to inches

Formula to convert centimetres to inches


 

Explanation of this Python Program

This Python program prompts the user to enter a height in inches, converts it to centimeters, and then prints the converted value. It uses the conversion factor of 2.54 to perform the conversion and rounds the result to two decimal places before displaying it to the user.

Here's an explanation of the provided Python program line by line:

python
inches = float(input('Enter the Height in inches to convert into centimeters:'))
  • This line prompts the user to enter a height in inches and assigns the entered value to the variable inches.
  • The input() function is used to receive input from the user, and float() is used to convert the input into a floating-point number.
python
centimeters = inches * 2.54
  • This line calculates the equivalent value in centimeters by multiplying the inches variable by the conversion factor 2.54.
  • The result is assigned to the variable centimeters.
python
centimeters = round(centimeters, 2)
  • This line rounds the value in centimeters to two decimal places using the round() function.
  • The rounded value is then assigned back to the centimeters variable.
python
print(inches, 'Inches =', centimeters, 'Centimeters')
  • This line displays the result of the conversion to the user.
  • The print() function is used to output a formatted string that includes the original inches value, the equal sign, and the converted centimeters value.


Comments

Popular posts from this blog

Explain different types of storage devices

Topic: Explain different types of storage devices in Computer systems Storage Devices Storage devices are used to store data and instructions permanently. Storage devices are also called secondary storage devices / backing storage devices / external storage devices or auxiliary storage devices. Examples of storage devices include Hard Disk, CD and DVD etc. Why Secondary Storage Devices are Used? Secondary storage devices are used because: Primary memory(RAM) is volatile and temporary. When computer is switched off, all data in ram is erased. Storage devices can store large amounts of data and instructions permanently whereas Primary memory has less capacity of storing data. Types Of Storage Devices There are three main types of storage devices:  Magnetic Tape   Magnetic Disk   Optical Disk   Flash Memory storage devices 1. Magnetic Tape Magnetic tape is the oldest storage device. It is made of plastic coated with m...

Explain Different Types Of Output Devices

Output devices Out put devices are used to display results of processing to the user. They perform the following functions:  Receive results from memory  Convert data into human readable form  Display results to the user Examples include: Monitor, printer, plotter, speaker, and multimedia projector. Different Types of Output Devices 1.    Monitor LCD Monitor CTR Monitor     Monitor is the most commonly used output device used to display results of processing. It has a TV like shape. Pictures on monitor are formed with picture elements called PIXEL. Monitors may be Monochrome that will display results in Black & White. Color Monitors are also available. They display results in multi colors. Monitor produces soft copy output. 2.    Printers Printers are used to produce hard copy out put. They print processing results on paper. Printers are divided into two main categories: · ...

Types Of Scanners Input Device

Scanner / Optical Scanner A scanner is an input device for computer. It can scan any printed document with text as well as images. It will : Read any printed paper or picture, Convert text or images into digital form Saves this converted digital file into computer storage for later use Uses Of Optical Scanners You can scan your documents or pictures to: Store into computer memory. To save lot of effort and time because if you type the whole text on printed page, it will take effort as well as time). Show image or text on computer screen or on a multimedia projector's screen. In addition, you can send this scanned document or image to your friends all over the world with the help of Internet & Email. You can publish the scanned documents or images on your website or blog. You can apply online and send the scanned images of your academic documents in any part of the world within minutes. If your scanner supports OCR - Optical Character Recognition, you can scan a page...