Answers for "calculator python code"

3

python bmi calculator code

print("Welcome to BMI calculator, by Abthahi Tazrian.")

# Offer Measurement Conversions

Offer_Conversions = input("Would you like to convert your imperial units to metric? (yes / no): ")

if Offer_Conversions == "yes":
    Imperial_Weight = input("What is your weight in pounds?: ")
    Imperial_Height = input("What is your height in feet (decimals)?: ")

    Imperial_Weight = float(Imperial_Weight)
    Imperial_Height = float(Imperial_Height)

    Metric_Converted_Weight = Imperial_Weight * 2.205
    Metric_Converted_Height = Imperial_Height * 30.48

    Metric_Converted_Weight = str(Metric_Converted_Weight)
    Metric_Converted_Height = str(Metric_Converted_Height)

    print("Your metric weight is " + Metric_Converted_Weight + " kg, please note this for the next stage.")
    print("Your metric height is " + Metric_Converted_Height + " cm, please note this for the next stage.")
    print("--")
elif Offer_Conversions == "no":
    print("--")

# Data Collection

Age = input("Put in your age: ")
Weight = input("Put in your weight in KG: ")
Height = input("Put in your height in CM: ")

# BMI Formula Calculation

Weight = float(Weight)
Height = float(Height)

Height_Squared = Height * Height
BMI_Formula_Assisted = Weight / Height_Squared
BMI_Formula_Completed = BMI_Formula_Assisted * 10000

# Health Chart Display

BMI_Formula_Completed = str(BMI_Formula_Completed)

print("You have a BMI score of " + BMI_Formula_Completed + ".")

BMI_Formula_Completed = float(BMI_Formula_Completed)

if BMI_Formula_Completed <= 18.5:
    print("You are underweight, consider gaining weight to bring your BMI to between 20 and 25.")
elif BMI_Formula_Completed <= 25:
    print("You are perfectly healthy, with a BMI within a healthy range of between 20 and 25.")
elif BMI_Formula_Completed <= 30:
    print("You are overweight, speak to a doctor about setting yourself a new target BMI between 20 and 25.")
elif BMI_Formula_Completed >= 30.1:
    print("You are obese, you need to lower your BMI to between 20 and 25 or else you may be at risks.")
Posted by: Guest on July-04-2020
0

python calculator

# define the function
def calculate():
    print('Please choose your operator adding(+) subtracting(-) multiplying(*) didviding(/) for power(**) for module(%)')

    number_1 = int(input("Enter your first digit: "))
    operation = input("Enter your operator: ")
    number_2 = int(input("Enter your first digit: "))


# adding
    if operation == '+':
        print('{} + {} = '.format(number_1, number_2))
        print(number_1 + number_2)
        print("You were adding.n")
        print("How do I know that I'm a smart progammer ;)n")

# subtracting
    elif operation == '-':
        print('{} - {} = '.format(number_1, number_2))
        print(number_1 - number_2)
        print("You were subtracting.n")
        print("How do I know that I'm a smart progammer ;)n")

# mulitplaying
    elif operation == '*':
        print('{} * {} = '.format(number_1, number_2))
        print(number_1 * number_2)
        print("You were mulitplaying.")
        print("How do I know that I'm a smart progammer ;)n")

# dividing
    elif operation == '/':
        print('{} / {} = '.format(number_1, number_2))
        print(number_1 / number_2)
        print("You were dividing.n")
        print("How do I know that I'm a smart progammer ;)n")

# for power
    elif operation == '**':
        print('{} ** {} = '.format(number_1, number_2))
        print(number_1 ** number_2)
        print("You were using for power.n")
        print("How do I know that I'm a smart progammer ;)n")

# module
    elif operation == '%':
        print('{} % {} = '.format(number_1, number_2))
        print(number_1 % number_2)
        print("You were using module.n")
        print("How do I know that I'm a smart progammer ;)n")

    # if they get a error
    else:
        print("Your number you have typed is invalid, please restart your program!")
    # add again() here as a function outside the calculate()
    again()


def again():
    cal_again = input("Do you want to calculate again? Y = yes or N = no: ")

    # Taking user input
    if cal_again.upper() == 'Y':
        calculate()
    elif cal_again.upper() == 'N':
        print('Leave kid ;-;')
    else:
        again()


def welcome():
    print("Welcome to my calculator made by Pepa pig lol made in python :D")


# use calculate() for the function
welcome()
calculate()
Posted by: Guest on October-07-2020

Python Answers by Framework

Browse Popular Code Answers by Language