Procedure Python Functions

Complete the challenges, use the starter code on Replit Teams


  1. [can skip] Create a function that draws a shape using the turtle with these conditions:

    • It must have at least three parameters

    • It must have a loop

    • Call the function four times with different arguments ( values for the parameters)

    • (no return)


  1. Create a function that calculates and returns the area of a triangle given two parameters

    • def triangle_area(b, h):

    • Call the function four times with different arguments ( values for the parameters)

    • print(triangle_area(5, 8))

      • Should print out "20"


  1. Create a function that accepts a phrase parameter and prints it out in a nice sentence

    • def printing(phrase):

    • Call the function with ("oh no") so it prints out:
      Your phrase is 'oh no'

    • Call the function with ("you fail") so it prints out:
      Your phrase is 'you fail'

    • Call the function with ("don't be a moron") so it prints out:
      Your phrase is 'don't be a moron'

    • (no return)


  1. Create a functions that accepts a list and prints out the items in the list

    • def list_print(l):

    • Call the function with ([12, 13, 14]) so it prints out:
      0 - 12
      1 - 13
      2 - 14

    • Call the function with (['a', 'b', 'c', 'd']) so it prints out:
      0 - a
      1 - b
      2 - c
      3 - d

    • Call the function with ([]) so it prints out:
      (no return)






Calls:

(i.e. these lines must be in your code)


print(triangle_area(5, 8))

print(triangle_area(3, 10))

print(triangle_area(2.2, 7.1))

print(triangle_area(0.12, 1.23))


printing("oh no")

printing("you fail")

printing("don't be a moron")


list_print([12, 13, 14])

list_print(['a', 'b', 'c', 'd'])

list_print([])