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 Application Software? Users can use Appli

Define Data and Information With Examples

DATA Data is the collection of raw facts and figures. Actually data is unprocessed, that is why data is called collection of raw facts and figures. Define Data and Information with Examples We collect data from different resources. After collection, data is entered into computer for processing. Data may be collection of words, numbers, pictures,  or sounds etc. Examples of Data 1) Student Data on Admission Forms When students get admission in a college. They fill admission form. This form  contains raw facts (data of student) like name, father’s name, address of student, obtained marks, photo graph etc. 2)    Data of Citizens During census, data of all citizens is collected. The staff will go house to house and collect data about citizens like number of persons living in a home, either they are literate or illiterate, number of children, data of each child, cast, religion, Computerized national Identity Card number, address, how many rooms and other facilities in the

Advantages and Disadvantages of Ring Network Topology

Topic: Advantages and Disadvantages of Ring Network Topology alongwith detailed working of Ring topology What Do You Mean by Ring Topology? In Ring topology, each computer is connected to the next computer such that last computer is connected to the first. Every computer is connected to next computer in the ring. Each computer retransmits what it receives from the previous computer. Suppose, computer A needs to send data to computer D. Now the computer A sends data to computer B. As computer B is not the destination computer, so it will retransmit data to computer C. Finally, Computer C will transfer data to computer D, the destination computer. When a node sends a message, the message is processed by each computer in the ring. If a computer is not the destination node, it will pass the message to the next node, until the message arrives at its destination. Advantages of Ring Network Topology 1. It is relatively less expensive than a star topology network. 2. In a Rin