unit 5 AP compsci

studied byStudied by 1 person
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

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 29 people
854 days ago
5.0(2)
note Note
studied byStudied by 11 people
979 days ago
5.0(1)
note Note
studied byStudied by 5 people
42 days ago
5.0(1)
note Note
studied byStudied by 5 people
826 days ago
5.0(1)
note Note
studied byStudied by 7 people
685 days ago
5.0(1)
note Note
studied byStudied by 1 person
48 days ago
5.0(1)
note Note
studied byStudied by 7 people
46 days ago
5.0(2)
note Note
studied byStudied by 59 people
831 days ago
5.0(2)

Explore top flashcards

flashcards Flashcard (104)
studied byStudied by 42 people
327 days ago
5.0(1)
flashcards Flashcard (67)
studied byStudied by 7 people
127 days ago
5.0(1)
flashcards Flashcard (45)
studied byStudied by 3 people
683 days ago
5.0(1)
flashcards Flashcard (92)
studied byStudied by 1 person
667 days ago
5.0(1)
flashcards Flashcard (120)
studied byStudied by 3 people
273 days ago
5.0(1)
flashcards Flashcard (95)
studied byStudied by 7 people
685 days ago
5.0(1)
flashcards Flashcard (46)
studied byStudied by 24 people
783 days ago
5.0(3)
flashcards Flashcard (54)
studied byStudied by 13 people
701 days ago
5.0(2)
robot