Difference between revisions of "HTTLACS: Ch 3 Exercises"

From WLCS
Line 11: Line 11:
 
'''Exercises:'''
 
'''Exercises:'''
 
# Define the term: '''function definition'''
 
# Define the term: '''function definition'''
# Where are '''all''' function definitions supposed to be placed? (HINT: It's like GvR)
+
# Where are '''all''' function definitions supposed to be placed?
 
# Define the term: '''function header'''
 
# Define the term: '''function header'''
 
# Define the term: '''function body'''
 
# Define the term: '''function body'''

Revision as of 13:27, 23 October 2012

Directions:

  1. Open a text editor (Applications->Accessories->gEdit Text Editor)
  2. Put your name at the top
  3. Save the file as YOURLASTNAME_ch3.txt
  4. Complete the exercises below in this file. If you use DrPython, then be sure to copy your code back into this file
  5. Be sure to number each of your answers!!

References:

Exercises:

  1. Define the term: function definition
  2. Where are all function definitions supposed to be placed?
  3. Define the term: function header
  4. Define the term: function body
  5. What does a function call do?
  6. Write a function named new_line() that prints out an empty line. Test it out with a function call.
  7. In the same program, write a function named three_lines() that calls new_line() and prints 3 blank lines. (HINT: new_line() should only be called 3 times)
  8. In the same program, write a function named nine_lines() that calls three_lines() and prints 9 blank lines. (HINT: three_lines() should only be called 3 times)
  9. In the same program, write a function named clear_screen() that calls a combination of nine_lines(), three_lines(), and new_line() to print out 25 blanks lines
  10. Define the term: parameter
  11. What is the parameter in the following function header? def f(x):
  12. Complete the function body for def f(x): so that the cube of x is printed out (HINT: x to the power of 3)

Submit:

  • Submit by sharing via Google Docs with Mr. Bui