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 Main Difference Between System Software and Application Software

Topic: Explain Main Difference Between System Software and Application Software            Differentiate between system software and application software Before , explaining the main differences between application software and system software, let us know the definitions of Application software and System software with examples. What is System Software: System software is a set of programs to control all components of computer and to manage overall operations of computer system. Differences between System software and application software System software is used as a base to install and run all application software. Examples of system software include: Operating Systems, like Microsoft Windows, DOS, Unix and Linux Device Drivers like Device driver software of a Printer (found on CD normally provided with the printer) Utility Programs like AVAST anti virus, Disk Scanners and File Viewers etc. What is Applicat...

CRT Monitors and Flat-panel LCD Monitors Differences

Difference between CRT monitors and Flat Panel (LCD) Monitors Differences between CRT Monitors and Flat-panel (LCD) Monitors CRT Monitors Flat-panel (LCD)Monitors 1 CRT monitors are low-priced and more economical than flat-panel (LCD) monitors. Flat-panel monitors are more costly than CRT monitors. 2 Commonly, CRT monitors are used with personal computers. In the beginning LCD monitors were used in lap top or note book computers, PDAs and smart phones. But now they available for PCs, too.  3 CRT monitors use Cathode Ray Tube (picture tube) Technology to show text and graphics on screen. Flat-panel monitors use LCD - Liquid Crystal Display technology or Gas Plasma technology. 4 CRT monitors need more power. LCD monitors uses less energy than CRT monitors. 5 CRT monitors take more space on desk. LCD monitors take less space on desk top. 6 ...

Discuss Differences Between RAM and ROM

We have already discussed the topics: 1. What is RAM, Explain Different Types of RAM 2. What is ROM Explain Different Types of ROM Here we discuss differences between RAM and ROM 13 Differences Between RAM and ROM Thirteen Differences Between RAM and ROM Sr # RAM ROM 1 RAM stands for Random Access Memory ROM stands for Read Only Memory. 2 RAM is a temporary memory. ROM is a permanent memory. 3 RAM is a volatile memory. ROM is a non volatile memory. 4 When computer is turned off, all data and programs are erased from RAM.  When computer is turned off, all data and programs are retained in ROM. 5 RAM is a Read / Write memory. Data can be read and written to RAM. ROM is a read only memory. Data from ROM only can be read and not written. 6 Data and programs in RAM can be changed. The contents of ROM cannot be changed. 7 Dat...