Write a program to calculate the distance of 1056 feet in terms of yards and miles.

As found in PriP 1.2, Data HandlingClass 12 Computer Science with Python by Sumita Arora is referred to in schools affiliated to but not limited to CBSE.

Q12. Write a program to calculate the distance of 1056 feet in terms of yards and miles. Given fixed values are 1 mile = 1760 yards and 1 yard = 3 feet

To convert a distance of 1056 feet into yards and miles, we need some steps to calculate that.

Steps to Calculate

  1. Convert feet to yards: Divide the number of feet by 3 (1 yard = 3 feet).
  2. Convert yards to miles: Divide the number of yards by 1760 (1 mile = 1760 yards).

Python Program

Here’s a simple Python program that performs these calculations:

Python
# Fixed values
feet_to_yards = 1 / 3  # 1 yard = 3 feet
yards_to_miles = 1 / 1760  # 1 mile = 1760 yards

# Given distance in feet
distance_feet = 1056

# Calculate distance in yards
distance_yards = distance_feet * feet_to_yards

# Calculate distance in miles
distance_miles = distance_yards * yards_to_miles

# Display the results
print(f"Distance in yards: {distance_yards:.2f} yards")
print(f"Distance in miles: {distance_miles:.6f} miles")

Example Usage and Output

The program prints the distance in both yards and miles, formatted to two decimal places for yards and six decimal places for miles.

Output
Distance in yards: 352.00 yards
Distance in miles: 0.200000 miles

This indicates that 1056 feet is equivalent to 352 yards and 0.2 miles.

"Spread the light within, illuminate the hearts around you. Sharing is not just an action, but a sacred journey of connecting souls."~ Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *