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 2220 people
... ago
4.7(3)
note Note
studied byStudied by 24 people
... ago
5.0(1)
note Note
studied byStudied by 42 people
... ago
5.0(2)
note Note
studied byStudied by 48 people
... ago
5.0(1)
note Note
studied byStudied by 452 people
... ago
5.0(3)
note Note
studied byStudied by 43 people
... ago
5.0(1)
note Note
studied byStudied by 19 people
... ago
4.5(2)
note Note
studied byStudied by 23406 people
... ago
4.5(119)

Explore top flashcards

flashcards Flashcard (41)
studied byStudied by 2 people
... ago
4.0(1)
flashcards Flashcard (26)
studied byStudied by 173 people
... ago
5.0(1)
flashcards Flashcard (48)
studied byStudied by 21 people
... ago
5.0(1)
flashcards Flashcard (41)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (47)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (22)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (20)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (22)
studied byStudied by 3 people
... ago
5.0(1)
robot