# Untitled

unknown

plain_text

a month ago

1.8 kB

2

Indexable

Never

^{}

import math def height_conversion(): print("""This program converts a person's height from feet and inches to meters and calculates the average height of a group in both feet & inches and meters.""") # Get the number of people in the group group_size = int(input("How many people are in your group? ")) heights_meters = 0 total_inches = 0 # Loop through each person in the group for i in range(1, group_size + 1): print(f"\nPerson {i}") # Get the height in feet and inches from the user height_str = input("Enter height in feet and inches, separated by a comma (e.g., '5, 11'): ") # Parse the input assuming it is correctly formatted feet, inches = map(int, height_str.split(',')) # Calculate the height in inches and meters height_inches = feet * 12 + inches height_meters = height_inches / 39.3700787 # Print the height in feet, inches, and meters print(f"Height of person {i} in feet and inches: {feet}'{inches}\"") print(f"Height of person {i} in meters: {height_meters:.2f}") # Accumulate the total height in meters and inches heights_meters += height_meters total_inches += height_inches # Calculate the average height avg_meters = heights_meters / group_size avg_inches = total_inches / group_size avg_feet = avg_inches // 12 avg_inches = avg_inches % 12 # Print the average height in feet, inches, and meters print(f"\nThe average height of your group in feet and inches: {int(avg_feet)}'{int(avg_inches)}\"") print(f"The average height of your group in meters: {avg_meters:.2f}") # Call the function height_conversion()

Leave a Comment