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 37 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 30 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 25 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 29 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 47 people
Updated ... ago
5.0 Stars(1)

Explore top flashcards

flashcards Flashcard89 terms
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard54 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard65 terms
studied byStudied by 88 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard32 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard36 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard64 terms
studied byStudied by 21 people
Updated ... ago
5.0 Stars(3)
flashcards Flashcard80 terms
studied byStudied by 10 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard20 terms
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)