price = 0.9
# Print the header    
print('Balls:    Price:        Balls:    Price:')

# Print prices in two columns
for balls in range(1,11):
    left = balls
    right = balls + 10
    skeletton = '{:^6}    {:^6.2f}        {:^6}    {:^6.2f}'
    print(skeletton.format(left, left*price, right, right*price))

"""
Explanation: Exercise 1: Ice Cream Cheat Sheet
End of explanation
"""


def get_category(bmi):
    '''
    A function which returns the category for a given bmi    
    '''
    if bmi < 15.0:
        return 'Very severely underweight'
    elif bmi < 16.0:
        return 'Severely underweight'
    elif bmi < 18.5:
        return 'Underweight'
    elif bmi < 25.0:
        return 'Normal'
    elif bmi < 30.0:
        return 'Overweight'
    elif bmi < 35.0:
        return 'Moderately obese'
    elif bmi < 40.0:
        return 'Severely obese'
    else:
        return 'Very severely obese'

def get_bmi(weight, height):
    '''
    This function takes the weight in [kg] and the height in [m] 
    It return the BMI. 
    '''
    return weight / height**2

def bmi_calculator(weight=None, height=None):
    '''
    A calculator which takes weight and heigt.
    It prints the bmi and corresponding category.
    If no or only one value is given it asks for both.
    '''
    if weight == None or height == None:
        print('This is a BMI calculator.')
    
        weight = float(input('Enter your weight (kg): '))
        height = float(input('Enter your height (m): '))
    else:
        status = 'Your weight is: {}\nYour height is: {}'
        print(status.format(weight, height))
        
    bmi = get_bmi(weight, height)
    category = get_category(bmi)
        
    skeletton = 'Your BMI is {:.1f}\nYour BMI category is {}'
    print(skeletton.format(bmi, category))


bmi_calculator(75, 1.74)
print('\n')
bmi_calculator(49, 1.85)
print('\n')
bmi_calculator(128, 1.71)

bmi_calculator(80,1.73)

"""
Explanation: Exercise 2: Body-Mass-Index
End of explanation
"""


def primes(limit):
    '''
    A function implementing the sieve of erathostenes.
    It take an upper limit and returns all prime numbers
    under this limit.
    '''
    status = [True] * limit
    status[0] = status[1] = False
    primes = []

    for (i, isprime) in enumerate(status):
        if isprime:
            primes.append(i)
            for n in range(i*i, limit, i):     
                status[n] = False

    return primes

primes(57140)[-2]

max_num = int(input('Calculate prime numbers under: '))
for n in primes(max_num):
    print(n, end = " ")

"""
Explanation: Exercise 3: Sieve of Erathostenes
End of explanation
"""


