예제 #1
0
def main() -> None:
    weight = 0
    height = 0

    while True:
        weight = input("Wat is uw gewicht (in kilogram)?\n")
        weight = weight.replace(",", ".")

        if (CheckInput.is_numeric(weight) or CheckInput.is_float(weight)) and CheckInput.is_positive(weight):
            break
        else:
            print("Dat is geen geldige invoer, probeer opnieuw!")
            continue

    while True:
        height = input("Wat is uw lengte (in centimeter)?\n")
        height = height.replace(",", ".")

        if CheckInput.is_numeric(height) and CheckInput.is_positive(height) and 2 <= len(height) <= 3:
            height = float(height) / 100
            break
        else:
            print("Dat is geen geldige invoer, probeer opnieuw!")
            continue

    bmi = calculate_bmi(weight, height)
    print("Uw BMI is: {0} u hebt {1}".format(str("{0:.2f}".format(bmi)).replace('.', ','), str(BmiEnum(health(bmi)))))
예제 #2
0
from random import randint
from Modules import CheckInput

__author__ = 'Owain'


while True:
    a = randint(1, 100)
    b = randint(1, 100)

    digit = 0

    while True:
        digit = input("Wat is {} + {}?\n".format(a, b))

        if CheckInput.is_numeric(digit):
            if CheckInput.is_positive(digit):
                break
            else:
                print("Dat is geen positief getal, probeer opnieuw!")
                continue
        else:
            print("Dat is geen geldig getal, probeer opnieuw!")
            continue

    if digit == a + b:
        print("Dit klopt! {} + {} = {}".format(a, b, a + b))
    else:
        print("Dit klopt niet! {} + {} = {}".format(a, b, a + b))
예제 #3
0
def smaller_than_pi(value):
    return int(value) < pi


def is_42(value):
    return int(value) == 42


def is_1(value):
    return int(value) == 1


while True:
    digit = input("Voer een getal in:\n")

    if CheckInput.is_numeric(digit):
        if CheckInput.is_positive(digit):
            break
        else:
            print("Dat is geen positief getal, probeer opnieuw!")
            continue
    else:
        print("Dat is geen geldig getal, probeer opnieuw!")
        continue

print("{} {}".format("Is dit getal groter dan 5?", bigger_than_5(digit)))
print("{} {}".format("Is dit getal kleiner dan pi?", smaller_than_pi(digit)))
print("{} {}".format("Is dit getal gelijk aan 42?", is_42(digit)))
print("{} {}".format("Is dit getal gelijk aan 1?", is_1(digit)))