%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np

from IPython.html.widgets import interact, interactive, fixed
from IPython.display import display

"""
Explanation: Interact Exercise 01
Import
End of explanation
"""


def print_sum(a, b):
    """Print the sum of the arguments a and b."""
    # YOUR CODE HERE
    c = a+b
    print(c)

"""
Explanation: Interact basics
Write a print_sum function that prints the sum of its arguments a and b.
End of explanation
"""


# YOUR CODE HERE
interact(print_sum, a=[-10, 10, 0.1], b=[-8, 8, 2]);

assert True # leave this for grading the print_sum exercise

"""
Explanation: Use the interact function to interact with the print_sum function.

a should be a floating point slider over the interval [-10., 10.] with step sizes of 0.1
b should be an integer slider the interval [-8, 8] with step sizes of 2.
End of explanation
"""


def print_string(s, length=False):
    """Print the string s and optionally its length."""
    # YOUR CODE HERE
    if length == False:
        print(s)
    elif length == True:
        length = len(s)
        print(s, length)

"""
Explanation: Write a function named print_string that prints a string and additionally prints the length of that string if a boolean parameter is True.
End of explanation
"""


# YOUR CODE HERE
interact(print_string, s='Hello World!', length=True);

assert True # leave this for grading the print_string exercise

"""
Explanation: Use the interact function to interact with the print_string function.

s should be a textbox with the initial value "Hello World!".
length should be a checkbox with an initial value of True.
End of explanation
"""


