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...

Electricity Bill Calculator Formulas in Excel

Today, we will discuss How to create an Electricity Bill Calculator Worksheet by using Electricity Bill Calculator Formulas in Excel . The following formulas will be used in Electricity Bill Calculator Worksheet: Q: Prepare a worksheet according to the following instructions: Create a worksheet in MS Excel according to the requirements Enter sample data of Electricity units consumed by customers in a city Apply formula to calculate Units Consumed Apply formula to calculate Electricity Charges Apply formula to calculate Surcharge Apply formula to calculate Bill Payable Note: Every formula will start from  =  Units Consumed Formula=D5-C5 Electricity Charges Formula=IF(E5>200, E5*15,IF(E5>100, 1000+(E5-100)*12, E5*10)) SURCHARGE FORMULA = IF(F5>5000, F5*5%,IF(F5>1000, F5*3%, 0)) BILL PAYABLE FORMULA = SUM(F5:G5) Download Excel Electricity Bill Calculation Worksheet Free  Image for Electricity Bill Calculator Formulas ...

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...