master
Selcuk Sari 4 years ago
parent 7513b7fdb6
commit d88c383df2

@ -1,11 +1,70 @@
# import os from logging import root
# import subprocess import os
import subprocess
class DirectoryItem():
def __init__(self,rootDir,name) -> None:
self.name = name
self.path = os.path.join(rootDir,name)
self.itemList = []
sList = os.listdir(self.path)
for p in sList:
self.itemList.append(DirectoryItem(self.path,p))
pass
def print(self):
print(self.path)
for i in self.itemList:
i.print();
def getItem(self,i):
return self.itemList[i]
class Firmware(DirectoryItem):
pass
class SubModule(DirectoryItem):
pass
class Project(DirectoryItem):
pass
# def __init__(self,rootDir,name) -> None:
# self.name = name
# self.path = os.path.join(rootDir,name)
# self.itemList = []
# sList = os.listdir(self.path)
# for p in sList:
# self.itemList.append(SubModule(self.path,p))
# pass
# def print(self):
# print(self.path)
# for i in self.itemList:
# i.print();
class Projects(DirectoryItem):
# def __init__(self, rootDir) -> None:
# self.itemList = []
# self.path = rootDir
# pList = os.listdir(self.path)
# for p in pList:
# self.itemList.append(Project(self.path,p))
# pass
# def print(self):
# print(self.path)
# for i in self.itemList:
# i.print();
# pass
pass
rootdir = './Projects'
# projects = os.listdir(rootdir);
# modules = [];
# firmwares = [];
# for project in projects:
# modules.append(os.listdir(os.path.join(rootdir,project)));
# print(modules);
# 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(): # def test():
@ -14,36 +73,12 @@
# print(projects); # print(projects);
def main():
# def main(): p = Projects(rootdir,"")
# # test(); p.print()
# # print("hello from main"); pass;
# pass;
# if __name__ == "__main__":
# main();
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.")
Loading…
Cancel
Save