Challenge - 06 - Procedures#

Note: Anywhere you see pass, you must remove it for your code to work.#

[1] Write a procedure sum_of_squares() that takes in three integers and returns the sum of their squares:#

def sum_of_squares(a, b, c):
    # note: remove the word pass below!
    # and replace it with your code
    pass

[2] Write a procedure half_length() that takes as arguments a string and returns a float representing half the string’s length:#

def half_length(s):
    # note: remove the word pass below!
    # and replace it with your code
    pass

[3] Write a procedure sum_code_points() that takes in three characters (single letter strings, e.g., ‘a’, ‘r’, ‘3’) and return the sum of their Unicode code points. From the Python docs:#

Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord(‘a’) returns the integer 97 … This is the inverse of chr().

Thus:

>>> ord('a')
97
>>> ord('b')
98
>>> ord('4')
52
def sum_code_points(x, y, z):
    # remember to substitute the keyword pass with your own code
    pass

[4] Write a procedure incr() that increments a float or integer by 1 and returns that incremented value#

def incr(x):
    pass

[5] Write a procedure get_last_chr() that returns the very last character of a string#

def get_last_chr(a_string):
    pass

[6] According to Newton’s second law of motion, force can be expressed as the product of mass and acceleration of the body. Write a procedure get_force() that, given the mass and acceleration of an object, returns the force.#

def get_force(mass, acceleration):
    pass

[7] Write a procedure abba_ize() that, taking in two strings, returns a string that is the first string, followed by two repetitions of the second string, followed by the first string.#

def abba_ize(a,b):
    pass