Open In App

Python program to convert meters in yards and vice versa

Improve
Improve
Like Article
Like
Save
Share
Report

Given the distance in either meter or yard, the task here is to generate a Python program that converts distance given in meters to yards and vice versa.

Examples:

Input: Length in Meter: 245
       Length in Yard : 100

Output: 245 Meter in Yard = 267.9344 
        100 Yards in Meter = 91.4403


Input: Length in Meter: 5
       Length in Yard : 20

Output: 5 Meter in Yard = 5.4680 
        20 Yards in Meter = 18.2881

Formula used – 

1 Meter = 1.09361 Yard

So from the above formula, 1 Meter is equivalent to 1.09361 yards, hence to convert meters to yards, simply multiply the distance given in meters by 1.09361, and to convert Yard to meter, we just have to divide length in Yard by 1.09361.

Below is the implementation.

Python3




meter = 5  # Length in Meter
yard = 20  # Length in Yard
 
# converting Meter to Yard
meter_to_yard = meter * 1.09361
 
# converting Yard to meter
yard_to_meter = yard / 1.09361
 
# printing the output
print("%d Meter in Yard = %.4f " % (meter, meter_to_yard))
print("%d Yard in Meter = %.4f " % (yard, yard_to_meter))


Output:

5 Meter in Yard = 5.4680  

20 Yard in Meter = 18.2881

Time Complexity: O(1)

Auxiliary Space: O(1)


Last Updated : 17 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads