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

Types Of e-Commerce

Types/Categories/Modes of e-commerce. There are three main types of e-commerce as follows: 1) Business To Consumer (B2C) B2C ecommerce consists of selling goods and services to individual consumers. In this type, consumers or customers can visit the website and purchase goods online. The website will have a StoreFront. This storefront will show product details, pictures and a shopping cart. Shopping cart is used to collect items to purchase. Advantages of B2C e-commerce B2C e-commerce has the following advantages: * Shopping can be faster and more convenient. * Offerings and prices can change instantaneously. * Broadband telecommunications will enhance the buying experience. 2) Business To Business (B2B) B2B e-commerce takes place between two businesses. One business provides services to other business. Examples of B2B include: Online Advertisement, recruiting, sales, marketing, technical support and training. For eample, some companies provide online purchasing...

Explain Different Types Of Computer Networks - LAN, MAN, WAN

Explain different types of computer networks:(LAN,WAN,MAN) Today, we will discuss the main types of computer networks on the basis of the maximum distance covered where they can be accessed and operate. The main types of computer networks are: LAN, WAN, MAN Explain different types of computer networks 1.    LAN - Local-Area Network 2.    WAN - Wide-Area Network 3.    MAN - Metropolitan-Area Network 1)LAN (Local Area Network) What is LAN or Local Area Network LAN stands for Local Area Network . It covers a small area. Most LANs are used to connect computers in a single building or group of near buildings. A network contained within a relatively small area, such as a classroom, school, or single building, is commonly referred to as a local area network. Hundreds or thousands of computers may be connected through LAN . LANs are used in office buildings, college or university campus etc. Local Area Networks can t...