def main(): w = float(input("Give me your weight [kg]: ")) h = float(input("Give me your height [m]: ")) bmi_result = bmi.bmi_calculator(w, h) bmi_stan = bmi.bmi_status(bmi_result) print("BMI status:", bmi_stan) advice(bmi_stan)
def main(): try: w = float(input('Give me your weight [kg]: ')) except ValueError as e: print('Err1', e) w = 0 try: h = float(input('Give me your height [m]: ')) except ValueError as e: print('Err2', e) h = 1 bmi_result = bmi.bmi_calculator(w, h) bmi_stan = bmi.bmi_status(bmi_result) print('BMI status: ', bmi_stan) advice(bmi_stan)
def check_bmi(w, h): return bmi.bmi_calculator(w, h)
def run_snake(): command = take_command() print(command) if "time" in command: time = datetime.datetime.now().strftime("%H:%M:%S") print(time) talk("current time is " + time) #elif "my project" in command: #project_app() elif "shut down" in command: talk("do you really want to swich off your pc") if "yes" in take_command(): shut_down.power_off() talk("finished") else: exit() elif "boot" in command: talk("Do you really want to restart your pc") if "yes" in take_command(): shut_down.reboot_pc() talk("finished") else: exit() elif "play" in command: song = command.replace("play", "") talk("playing" + song) youtb.playonyt(song) elif "body mass index" in command: bmi.bmi_calculator() elif "text" in command: #will write what i will say command = command.replace("text", "") myText = open( r'C:\Users\Cristian\AppData\Local\Programs\Python\Python39\Lib\voice_assistant\voice_command.txt', 'a+') mystring = command myText.write(mystring + "\n") myText.close() #elif "body mass index" in command: #os.system(r'C:\Users\Cristian\AppData\Local\Programs\Python\Python39\Lib\BMI\dist\bmi\bmi.exe') #exit() elif "wikipedia" in command: person = command.replace("wikipedia", "") info = wikipedia.summary(person, 5) talk(info) text_info = open( r'C:\Users\Cristian\AppData\Local\Programs\Python\Python39\Lib\voice_assistant\wikipedia.txt', 'a+') my_text = info text_info.write(my_text + "\n") text_info.close() elif "random fact" in command: facts = randfacts.getFact(True) talk(facts) print(facts) elif "search" in command: command = command.replace("search", "") pywhatkit.search(command) elif "dictionary" in command: command = command.replace("dictionary", "") dit = PyDictionary() meaning = dit.meaning(command) talk(meaning) inf_dex = open( r'C:\Users\Cristian\AppData\Local\Programs\Python\Python39\Lib\voice_assistant\dictionar.txt', 'a+') inf_dex.write(str(meaning) + "\n") inf_dex.close() elif "translate" in command: command = str(command.replace("translate", "")) translator = Translator(to_lang="romanian") var_t = translator.translate(command) nf_translate = open( r'C:\Users\Cristian\AppData\Local\Programs\Python\Python39\Lib\voice_assistant\translate.txt', 'a+') nf_translate.write(str(var_t) + "\n") nf_translate.close() talk(var_t) print(var_t) elif "battery" in command: battery_percent.battery() elif "exit " in command: exit() else: raise Exception("error")