You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
# import os
|
|
# import subprocess
|
|
|
|
# list_files = subprocess.run(["ls", "-l"])
|
|
# # list_files2 = subprocess.run(["echo \"Hello World\" && echo \"Hello world 2\""])
|
|
# list_files2 = subprocess.run(["echo Hello World && echo Hello World 2",""]);
|
|
# print("The exit code was: %d" % list_files.returncode)
|
|
# print("The exit code was: %d" % list_files2.returncode)
|
|
|
|
|
|
# def test():
|
|
# rootdir = './Projects'
|
|
# projects = os.listdir(rootdir);
|
|
# print(projects);
|
|
|
|
|
|
|
|
# def main():
|
|
# # test();
|
|
# # print("hello from main");
|
|
# pass;
|
|
|
|
|
|
# if __name__ == "__main__":
|
|
# main();
|
|
|
|
|
|
|
|
def gather_info():
|
|
height = float(input("What is your height? (inches or meters) "))
|
|
weight = float(input("What is your weight? (pounds or kilograms) "))
|
|
system = input("Are your measurements in metric or imperial systems? ").lower().strip()
|
|
return (height, weight, system)
|
|
def calculate_bmi(weight, height, system='metric'):
|
|
if system == 'metric':
|
|
bmi = (weight / (height ** 2))
|
|
else:
|
|
bmi = 703 * (weight / (height ** 2))
|
|
return bmi
|
|
while True:
|
|
height, weight, system = gather_info()
|
|
if system.startswith('i'):
|
|
bmi = calculate_bmi(weight, system='imperial', height=height)
|
|
print(f"Your BMI is {bmi}")
|
|
elif system.startswith('m'):
|
|
bmi = calculate_bmi(weight, height)
|
|
print(f"Your BMI is {bmi}")
|
|
else:
|
|
print("Error: Unknown measurement system. Please use imperial or metric.") |