Skip to content

Instantly share code, notes, and snippets.

@vanderhoop
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save vanderhoop/b4ae35f85ae496fdd54f to your computer and use it in GitHub Desktop.

Select an option

Save vanderhoop/b4ae35f85ae496fdd54f to your computer and use it in GitHub Desktop.

Practice Writing and Invoking Methods

  1. Define a method, sings_fav_lyric that takes a lyric as input and print that lyric to the console as if it's been screamed (think all caps and a bunch of exclamation points)
  2. Call your new sings_fav_lyric method, passing your favorite lyric as input.
  3. Define a method, calculate_volume that takes three inputs: length, width, and height, and returns the calculated volume.
  4. Call this method with values of your choosing and save the output to a variable called volume.
  5. Define a method, calculate_tip which takes a single input called meal_value and returns a value equal to 20% of any given meal value.
  6. Call this method with a value of your choosing and save the output to a variable called tip.
  7. Write another method calculate_custom_tip that takes two arguments: meal_value and tip_percentage. Define this method such that when calculate_custom_tip(10.00, 20) is entered into the console, it returns the string "You should tip your server 2 dollars".
  8. Invoke your calculate_custom_tip with the values above and save the output to a variable called custom_tip_amount
  9. Invoke this method again and again with different values, saving the output to new variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment