0% found this document useful (0 votes)
744 views2 pages

Unit 7 Lesson 2 Parameters and Return Investigate

The document discusses functions with parameters and return values to simplify code. It provides examples of functions that can have no parameters/return values, parameters but no return values, return values but no parameters, and parameters and return values. It then provides prompts and modifications for three levels of a coding exercise involving using parameters and return values in functions to filter and process data. The takeaways are that extracting shared features into generalized functions with parameters improves code readability and manages complexity through code reuse.

Uploaded by

Jayden Luke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
744 views2 pages

Unit 7 Lesson 2 Parameters and Return Investigate

The document discusses functions with parameters and return values to simplify code. It provides examples of functions that can have no parameters/return values, parameters but no return values, return values but no parameters, and parameters and return values. It then provides prompts and modifications for three levels of a coding exercise involving using parameters and return values in functions to filter and process data. The takeaways are that extracting shared features into generalized functions with parameters improves code readability and manages complexity through code reuse.

Uploaded by

Jayden Luke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit 7 Lesson 2 Parameters and Return Investigate

Prompt:
Are clean and organized programs more useful for computers or people?

Why?

Try to give examples from programs you've written or seen in this class.

Review
● Functions with parameters and return values help us simplify our code
● Functions can only return one value at a time
● A function can have:
○ No parameters and no return values
○ Parameters, but no return values
○ Return values, but no parameters
○ Parameters and return values

Navigate to Level 2 on Code Studio--Video to follow along with

Level 2 - Follow the instructions, for discussion, add your thoughts here then do the modifications

1. How does calculate() work?


Figures out what mathematical symbol is being used and uses the numbers.

2. What are the arguments passed through the parameter in calculate() when it is called?
symbol
3. What types of data does the parameter require in the calculate() function? Where can you find that
information?
It requires the symbol
4. What is returned? What type of data?
The string
Do This:
● Look at lines 30-36. Look at how the MOD operator % works. Watch the video walk-through about MOD.
Modify: Make these changes to the code

● Add a divide button.


● In addition to displaying if the number is even or odd, display if the number is divisible by 3.

Level 3 - Follow the instructions, for discussion, add your thoughts here then do the modifications

1. Lines 1 - 14: Read the code carefully. What is happening here?


Every time a button is used it runs the filtered function
2. Read the function on lines 15-34 carefully. After you are done, explain how the function works,
what parameters it takes and what is returned.
It filters through the world list and returns all worlds to the start
3. How does the Word Game Helper work?
Give the length and starting letter and returns all the words

Modify: Extra Time?

● Remove the letter dropbox and replace it with an input box. Update the code so the user
can type any number of letters, and only words that start with those letters and are the
specified length will be displayed.

Takeaways:

Extracting shared features to generalize functionality is known as procedural


abstraction.

Using parameters allows the functions (also called procedures) to be generalized.

Using procedural abstraction helps improve code readability.

Procedural abstraction manages complexity by allowing for code reuse.

● For example: the function move(id, direction) could be used to move an


element in any direction, rather than writing separate functions for each direction.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy