<jupyter_start><jupyter_text>Exercise 3Add the specified code for each code cell, running the cells _in order_. Define a function `add_three` that takes a single argument and returns a value 3 greater than the input.<jupyter_code>def add_three(number):
    return number+3<jupyter_output><empty_output><jupyter_text>Create and output a variable `ten` that is the result of passing `7` to your `add_three()` function.<jupyter_code>ten=add_three(7)
print(ten)<jupyter_output>10<jupyter_text>Create a variable `ten_str` that is the result of passing `"7"` to your `add_three()` function. What does this tell you about how the function should be described (e.g., in a doc string)?<jupyter_code>ten_str=add_three("7")
argument should be integer<jupyter_output><empty_output><jupyter_text>Define a function `imperial_to_metric` that takes in two arguments: a number of feet and a number of inches. The function should return the total length in meters. _Include an appropriate doc string_.<jupyter_code>def imperial_to_metric(num_feet,num_inches):
    """
    summary
    parameters:
    argument1 : number of feet
    argument2 : number of inches
    returns:
    total length in meters
    """
    num_feet=num_feet*.3048
    num_inches=num_inches*.0254
    return num_feet+num_inches<jupyter_output><empty_output><jupyter_text>Create and output variable `height_in_meters` by passing your height in imperial to the `imperial_to_metric()` function.<jupyter_code>height_in_meters=imperial_to_metric(5,4)
print(height_in_meters)<jupyter_output>1.6256<jupyter_text>Define a function `compare_str_length` that takes in 2 strings, and returns a sentence of the form```"The difference in string lengths is N"```Include an appropriate doc string.<jupyter_code>#some changes
def compare_str_length(str1,str2):
    """
    parameters:str1,str2 two strings
    returns: difference in lengths
    """
    N=abs(len(str1)-len(str2))
    print("The difference in string lengths is ",N)<jupyter_output><empty_output><jupyter_text>Pass two strings of different lengths to your `compare_str_length()` function.<jupyter_code>compare_str_length("two","three")<jupyter_output>The difference in string lengths is  2<jupyter_text>Define a function `fraction_str()` that takes two parameters, a numerator and a denominator, and outputs a string version of that that fraction (e.g., `"3/4"`). Make the parameters be **keyword arguments** with default values of 1.<jupyter_code>def fraction_str(num=1,denom=1):
    """
    parameters:two numbers
    returns:string version of the fraction
    """
    return (str(num)+"/"+str(denom))<jupyter_output><empty_output><jupyter_text>Call the `fraction_str()` function with named arguments to produce the string `"5/11"`. Print the result.- For fun: try listing the denominator argument before the numerator argument! What happens?<jupyter_code>fraction_str(denom=5,num=11)<jupyter_output><empty_output><jupyter_text>Call the `fraction_str()` function only specifying a denominator of `3`. Print the result<jupyter_code>fraction_str(denom=3)<jupyter_output>1 / 3<jupyter_text>Call the `fraction_str()` function using **positional arguments** (unnamed) to produce the string `"11/5"`. Print the result.<jupyter_code>fraction_str(11,5)<jupyter_output>11 / 5
StarcoderdataJupyterStructuredCleanDedup