Difference between revisions of "HTTLACS: Ch 3 Exercises"

From WLCS
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
'''Directions:'''
 
'''Directions:'''
# Open a text editor (Applications->Accessories->gEdit Text Editor)
+
# Open a new Google Drive document
 
# Put your name at the top
 
# Put your name at the top
# Save the file as YOURLASTNAME_ch3.txt
+
# Title the document as YOURLASTNAME_ch3
# Complete the exercises below in this file.  If you use DrPython, then be sure to copy your code back into this file
+
# Complete the exercises below in this file.  If you use WingIDE, then be sure to copy & paste your code into the Google Doc
 
# Be sure to number each of your answers!!
 
# Be sure to number each of your answers!!
  
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'''
 
# What does a '''function call''' do?
 
# What does a '''function call''' do?
# Write a function named '''new_line()''' that prints out an empty line.  Test it out with a function call.
+
# Define a function named '''new_line()''' that prints out an empty line.  Test it out with a function call to new_line()
# 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)
+
# Define a function named '''printHighFive()''' that prints out "High five!" 5 times. Test it out with a function call to printHighFive().
# 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)
+
# Define a function named '''print25High()''' that calls printHighFive() 5 times so that "High five" is shown 25 timesTest it out with a function call to print25High()
# 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
 
 
# Define the term: '''parameter'''
 
# Define the term: '''parameter'''
 
# What is the parameter in the following function header? '''def f(x):'''
 
# What is the parameter in the following function header? '''def f(x):'''
Line 24: Line 23:
  
 
'''Submit:'''
 
'''Submit:'''
* Submit by sharing via Google Docs with Mr. Bui
+
* Submit to Mr. Bui via [http://classroom.google.com Google Classroom]

Latest revision as of 13:21, 1 October 2014

Directions:

  1. Open a new Google Drive document
  2. Put your name at the top
  3. Title the document as YOURLASTNAME_ch3
  4. Complete the exercises below in this file. If you use WingIDE, then be sure to copy & paste your code into the Google Doc
  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. Define a function named new_line() that prints out an empty line. Test it out with a function call to new_line()
  7. Define a function named printHighFive() that prints out "High five!" 5 times. Test it out with a function call to printHighFive().
  8. Define a function named print25High() that calls printHighFive() 5 times so that "High five" is shown 25 times. Test it out with a function call to print25High()
  9. Define the term: parameter
  10. What is the parameter in the following function header? def f(x):
  11. 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: