• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/36

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

36 Cards in this Set

  • Front
  • Back
Function
A special type of module whose purpose is performing a specific task.
What happens when a program finishes?
The function returns a value back to the part of the program that called it and then can be used like any other value.
How are values used?
1. Assigned a variable
2. Displayed on screen
3. Used in a mathematical expression
Library Functions
Built in functions that have already been written into the into the programming language that you can call anytime you need them.
Benefits of library functions
Makes programming easier because these functions perform many of the taks that programmers commony need to perform.
Examples of what library functions do
manipulate numbers, perform various math operations, convert data from one type to another, manipulate strings, etc.
What happens when you call a function?
The compiler/interpreter automatically causes the function to execute without requiring the function's code to appear in your program
What do you need to know when using library functions?
1. Purpose of the library function
2. Arguments you must pass to it
3. The type of data it returns
Black Box
Any mechanism that accepts input, performs some operation that cannot be seen on the input, and produces output.
random Function
A library function that generates random numbers.
randomize() in vb
Uses for the random function
Useful for simulation programs - formulas can be constructed in which a random number is used to determine various actions and events that take place in the program.
Calling a random function
set number = random(1, 100)
When the function is called, it will generate a random number 1-100 and then return the number, which is then assigned to the number variable.
Custom Functions
Essentially modules/subroutines that allow you to send a value back to the part of the program that called it
Function Header
1. Specifies data type of returned value
2. Name of the function
3. Parameter variables used to accept arguments
Function Body
One or more statements that execute when the function is called
Return Statement
Statement in the body which specifies the value that is returned from the function when it ends.
Parts of a Function Header
dataType of return value and function name
Return Value
Last line of the body. Value that the function sends back to the part of that calls the function
How many arguments can you pass into a function?
As many arguments as you need, but you can only return one value.
Uses of Functions
1. Can prompt user for input and then return the value entered by the user
2. Simlify complex mathematical expressions
IPO Chart
Input, processing, output. Describes the input, processing, and output of a function. Used to design functions.
Uses of Boolean Functions
Help to simplfy complex conditions that are tested in decision and repetition structures (roulette game, hello!)
Designing Boolean Functions
The function accepts a number as an argument and returns "True" if the conditions are true, or "False" if the conditions are otherwise. (cool!)
Mathematical Library Functions
Many programming languages offer many mathematical functions in the library.
Data Type Conversion Functions
Library Functions that convert values from one data type to another. Example: toInteger. See page 243 for these functions
Type Mismatch Error
An error that occurs when a programmer tries to assign a value of one data type to a variable of another data type.
Length Function
returns the length of a string
Append Function
accepts two strings as arguments and returns a third string that is created by appending the second string to the end of the first string. This is called "concatenation"
toUpper Function
accepts a string as an argument and returns a copy of the argument as uppercase
toLower Function
same as toUpper but converts the copy to lowercase instead
Substring Function
substring is a string within a string and the function returns sections of the string that you wish to call back
Contains Function
accepts 2 strings as arguments, returns True if the first string contatins the second string
stringToInteger Function
Converts a string to an integer
stringToReal Function
Converts a string to an integer
isInteger Function
determines whether a string can be converted to an integer
isReal Function
determines whether a string can be converted to a real