Beispiel #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)))))
Beispiel #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))
Beispiel #3
0
from Modules import CheckInput

__author__ = 'Owain'


def convert_to_miles(val):
    return float(val) * 0.6214

digit = 0

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

    if CheckInput.is_float(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(convert_to_miles(digit))

# Line: A sequence of zero or more non- <newline> characters plus a terminating <newline> character.
Beispiel #4
0
from Modules import CheckInput

__author__ = 'Owain'


def diminutive(val):
    return val + "tje"

value = None

while True:
    value = input("Voer een woord in:\n")

    if not CheckInput.single_character(value) and CheckInput.only_letters(value):
        break
    else:
        print("Dat is geen woord, probeer opnieuw!")
        continue

print(diminutive(value))

# Line: A sequence of zero or more non- <newline> characters plus a terminating <newline> character.
Beispiel #5
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)))
Beispiel #6
0
from Modules import CheckInput

__author__ = 'Owain'

char = None
digit = 0

while True:
    char = input("Voer een letter in:\n")
    if CheckInput.only_letters(char):
        if CheckInput.single_character(char):
            break
        else:
            print("Dat zijn meerdere letters, probeer opnieuw!")
    else:
        print("Dat is geen letter, probeer opnieuw!")
        continue

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 getal, probeer opnieuw!")
        continue