# docx

Document Sample

```					                                                                                   Chapter 10 Worksheet

Name: ________________________

Section: ________________________

Writing code
1. Write a function that prints out “Hello World.”

2. Write code that will call the function in problem 1.

3. Write a function that prints out “Hello Bob”, and will take a parameter to let the caller specify
the name. Do not put an input statement inside the function! Use a parameter.

4. Write code that will call the function in problem 3.
Chapter 10 Worksheet

5. Write a function that will take two numbers as parameters (not as input from the user) and print
their product (i.e. multiply them).

6. Write code that will call the prior function.

7. Write a function that takes in two parameters. The first parameter will be a string named
phrase. The second parameter will be a number named count. Print phrase to the screen
count times. (e.g., the function takes in “Hello” and 5, then prints “Hello” five times.)

8. Write code to call the previous function.
Chapter 10 Worksheet

9. Write code for a function that takes in a number as a parameter, and returns the square of that
number. Note, this function should return the answer, not print it out.

10. Write code to call the function above and print the result.

11. Write a function that takes three numbers as parameters, and returns the centrifugal force. The
formula for centrifugal force is:
F=mrω2
F is force, r is radius, ω is angular velocity, m is mass.

12. Write code to call the function above and print the result.

13. Write a function that takes a list of numbers as a parameter, and prints out each number
individually using a “for” loop.

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 0 posted: 11/20/2013 language: Unknown pages: 3