unit 5 AP compsci

studied byStudied by 1 person
0.0(0)
Get a hint
Hint

why do we use functions

1 / 16

17 Terms

1

why do we use functions

helps us understand the code easier

makes code less repetitive and more organized

makes code reusable

New cards
2

Parameters

The inputs/what goes into a function

Order matters

New cards
3

local variables

defined inside a function/loop and can only be used inside that function/loop

New cards
4

global variables

can be used anywhere in the code

ex: constanants

New cards
5

scope

the area of code that a variable can be used in

New cards
6

why do we need scope

differentiate variables with the same name in different parts of code

(cannot have 2 variables with the same name within the same scope)

New cards
7

What does API stand for

Application Programming Interference

New cards
8

what does api do

Set of tools for buliding programs

Helps two programs connect or communicate with each other

Helps devices connect and connects devices to programs

New cards
9

API examples

spotify, twitter

New cards
10

return value

returns the value when the function is called, does not print value unless println is used

New cards
11

What part of the function is bolded?

function start(){

var numApples = 4;

println("Before: " + numApples);

var twiceAsMany = doubleNumber(numApples);

println("After: " + twiceAsMany);

}

function doubleNumber(x){

var doubledX = 2 * x;

return doubledX;

calling the function

New cards
12

What part of the function is bolded?

function start(){

var numApples = 4;

println("Before: " + numApples);

var twiceAsMany = doubleNumber(numApples);

println("After: " + twiceAsMany);

}

function doubleNumber(x){

var doubledX = 2 * x;

return doubledX;

defining the function

New cards
13

What part of the function is bolded?

function start(){

var numApples = 4;

println("Before: " + numApples);

var twiceAsMany = doubleNumber(numApples);

println("After: " + twiceAsMany);

}

function doubleNumber(x){

var doubledX = 2 * x;

return doubledX;

function body

New cards
14

What part of the function is bolded?

function start(){

var numApples = 4;

println("Before: " + numApples);

var twiceAsMany = doubleNumber(numApples);

println("After: " + twiceAsMany);

}

function doubleNumber(x){

var doubledX = 2 * x;

return doubledX;

return value statement

New cards
15

What part of the function is bolded?

function start(){

var numApples = 4;

println("Before: " + numApples);

var twiceAsMany = doubleNumber(numApples);

println("After: " + twiceAsMany);

}

function doubleNumber(x){

var doubledX = 2 * x;

return doubledX;

parameter

New cards
16

syntatic validation

enforces correct syntax on structures fields

ex: 9 digits in SSN, date in correct form

New cards
17

semantic validation

enforces the correctness of the values in the specific business context

ex: start date is before end date

New cards

Explore top notes

note Note
studied byStudied by 31 people
... ago
4.0(1)
note Note
studied byStudied by 16 people
... ago
4.0(1)
note Note
studied byStudied by 27 people
... ago
5.0(1)
note Note
studied byStudied by 14 people
... ago
5.0(1)
note Note
studied byStudied by 20 people
... ago
5.0(1)
note Note
studied byStudied by 4 people
... ago
5.0(1)
note Note
studied byStudied by 18 people
... ago
5.0(1)
note Note
studied byStudied by 6 people
... ago
5.0(3)

Explore top flashcards

flashcards Flashcard (25)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (31)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (278)
studied byStudied by 27 people
... ago
5.0(2)
flashcards Flashcard (71)
studied byStudied by 26 people
... ago
5.0(1)
flashcards Flashcard (45)
studied byStudied by 4 people
... ago
5.0(1)
flashcards Flashcard (282)
studied byStudied by 31 people
... ago
5.0(1)
flashcards Flashcard (135)
studied byStudied by 3 people
... ago
5.0(1)
flashcards Flashcard (35)
studied byStudied by 53 people
... ago
5.0(2)
robot