Difference between revisions of "HTTLACS: Ch 3 Exercises"

From WLCS
 
(8 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!!
 +
 +
'''References:'''
 +
* [http://openbookproject.net/thinkcs/python/english2e/ch03.html How to Think Like a Computer Scientist: Chapter 3]
  
 
'''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
+
# Define a function named '''new_line()''' that prints out an empty line.  Test it out with a function call to new_line()
 +
# Define a function named '''printHighFive()''' that prints out "High five!" 5 times.  Test it out with a function call to printHighFive().
 +
# 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()
 +
# Define the term: '''parameter'''
 +
# What is the parameter in the following function header? '''def f(x):'''
 +
# 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:'''
* Submit the file to [http://wlhs.schoolweblockers.com/ School Web Lockers]
+
* 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: