AP CSP Unit 1, 3-5
onEvent(id, type, function(event) { ... });
Code used in the App Lab to check for user input (i.e. a user clicking a mouse or touching a particular place on a screen)
Input
Data that are sent to a computer for processing by a program. Can come in a variety of forms, such as tactile interaction, audio, visuals, or text. (e.g Clicking a button on an app)
Digital Data
Data that changes discreetly through a finite set of possible values
Analog Data
Data with values that change continuously, or smoothly, over time. Some examples of analog data include music, colors of a painting, or position of a sprinter during a race.
Layers of Abstraction in Color Images
Digital Image layer, sampling layer, pixel layer, binary layer
setScreen(screenId)
Switches screens to a given "screenID".
Transversal
The process of accessing each item in a list one at a time
Random List Access Pattern
a coding pattern that allows a user to see random elements in a list
Program
a collection of program statements. Programs run (or "execute") one command at a time.
Program Statement
a command or instruction. Sometimes also referred to as a code statement.
Function Call (e.g. lazyCat () ; this calls the lazyCat function)
a command that executes the code within a function
Function e.g. function lazyCat ( ) { code here }
a named group of programming instructions. Also referred to as a "procedure".
Computers represent numbers with.....
bits that are either 0s or 1s
Open Access Research
Research that is published to the internet to share with everyone.
Low Sampling Rate
Provides lower quality music or images but requires less data and processing from the computer.
Functions are helpful because...
1) They remove repetitive code 2) They make code easier to edit 3) They better organize your code
0000 1011
11
Which number is larger 11000 or 01111?
11000
1000 0000
128
0000 1111
15
0001 0000
16
What is the highest number you can represent with 8 bits?
255
How many total numbers can you represent with 8 bits?
256
What is the minimum number of bits per pixel you need for color digital images?
3 bits
0010 0000
32
How many bits do you need to represent 19 in binary?
5
0100 0000
64
A byte equals _____ bits.
8
Overflow Error
A calculation produces a result that is greater than the computer can deal with or store with the available number of bits
ASCII
A code for representing English characters as numbers, with each letter assigned a number from 0 to 127 and then converted into binary for the computer.
Psuedocode
A cross between human language and a programming language. NOT a REAL coding language.
randomNumber(min, max)
Returns a random number in the closed range from min to max.
Creative Commons
A kind of copyright that makes it easier for people to copy, share, and build on your creative work, as long as they give you credit for it.
Design specification
A list of requirements, constraints and considerations that a yet-to-be-designed product must fulfill. Sometimes to show this, you can make a diagram of how the app will look and work.
For Loop
A loop that continues for a specific number of steps.
While Loop
A loop that continues to repeat while a condition is true.
Sampling
A process for creating a digital representation of analog data by measuring the analog data at regular intervals called samples.
Lossless Compression
A process for reducing the number of bits needed to represent something (e.g. text) WITHOUT losing any information. This process IS REVERSIBLE.
Lossy Compression
A process for reducing the number of bits needed to represent something in which some information is lost or thrown away. This process is NOT reversible.
string
A sequence of characters that are surrounded by " " marks.
Definition of Abstraction
A simplified representation of something more complex. Abstractions allow you to hide details to help you manage complexity, focus on relevant concepts, and reason about problems at a higher level.
Rounding Error
A type of error when you have to round a value up or down so the value fits into a given number of bits.
Global Variable
A variable whose scope is "global" to the program, it can be used and updated by any part of the code. It is declared at very beginning of a program.
Local Variable
A variable with local scope is one that can only be seen, used and updated by code within the same scope. Typically this means the variable was declared (created) inside a function -- includes function parameter variables.
&&
AND
Output
Any data that are sent from a program to a device. Can come in a variety of forms, such as tactile interaction, audio, visuals, or text. (e.g. Your phone playing a song.)
getNumber(id)
Gets the number from the specified screen element like a text input element.
getText(id)
Gets the text from the specified screen element like a text input element.
index number
How the computer numbers each item in a list.
Counter Pattern
Increasing or decreasing numbers is a common and incredibly useful pattern in programming. This can be used to make an image fly across the screen, to count down a timer, or to keep track of clicks. var x = 0; onEvent("button1", "click", function( ) { x = x + 1; });
!=
Not equal to
Binary Numbers
Number system with a base of 2, unlike the number systems most of us use that have bases of 10. Binary numbers are preferred for computers for precision and economy. An electronic circuit that can detect the difference between two states (on-off, 0-1) is easier and more inexpensive to build than one that could detect the differences among ten states (0-9).
||
OR
playSound(url, loop);
Program will play a sound at a specified "url". You can also tell the sound to play once or in a "loop"
Bugs
Programming errors.
High Sampling Rate
Provides better quality music or images but requires more data and processing from the computer.
How can you tell 0000 1010 1111 0000 1101 is odd?
The first bit on the right is a 1.
User Interface (UI)
The inputs and outputs that allow a user to interact with a piece of software. User interfaces can include a variety of forms such as buttons, menus, images, text, and graphics.
Who owns online materials?
The original creator is always the owner unless they license the material.
0001
This binary number is equal to 1
0010
This binary number is equal to 2
0100
This binary number is equal to 4
myAge2
This is a good variable name.
variable = [ ]
This is how you declare and empty list variable.
variable.length
This tells you the number of items in a list variable.
variable1
This variable name is not specific to its use. It does not describe what it is for.
my Age2
This variable name should not have a space in it.
2myAge
This variable name should not start with a number.
console.log("Hi!");
This will print a string to the console log.
variable.length-1
This will take you to the last item in a list.
An example of Abstraction
Typing text messages. You hit the key on the screen. It is translated into a number, then into binary and finally an electrical pulse which prints the letter in your text.
Comments
Using descriptive text to explain portions of code. Comments do not change the way a program behaves, but are important for the programmer to remember what the code does.
When do we want to use Lossy Compression?
Whenever we need to save storage space or when download speed is more important than quality.
When do we want to use Lossless Compression?
Whenever we need to save the original file and if we want high quality images or sounds. This is used with all text files and with images or music when we want to preserve the original.
Can you use online materials?
Yes, as long as you have permission and/or you cite your sources(e.g. You give the original creator credit.)
Translate into JavaScript: IF the clicks go above 5, make the star red.
if(clicks > 5){ setProperty("star", "icon-color", "red"); }
Translate into JavaScript: IF the clicks go above 5, make the star red OTHERWISE keep the star black.
if(clicks > 5){ setProperty("star", "icon-color", "red"); } else { setProperty("star", "icon-color", "black"); }
Boolean Expression
in programming, an expression that evaluates to True or False.
setProperty(id, property, value)
lets your app change any property listed in Design mode for a given UI element.
Open Source Software
noncommercial software shared freely and developed collectively on the internet
UI Elements
objects, like buttons, images, text boxes, pull down menus, screens and so on.
Translate into JavaScript: When I click the "buttonLike", increase likes by 1.
onEvent("buttonLike", "click", function( ) { likes = likes + 1; });
Translate into JavaScript: When I click the button, update "labelCounter" with the variable "likes".
onEvent("buttonLike", "click", function( ) { setProperty("labelCounter", "text", likes); });
Adding 0001 to 1111 with only four bits of memory will result in a __________________________________.
overflow error.
List Scrolling Pattern
pattern that allows a user to click through all the items in the list.
Sequential Programming
program statements run in order, from top to bottom. -No user interaction -Code runs the same way every time
Trying to represent 2.5 with 0010 or 0011 will result in a _______________________________________.
rounding error
Event Driven Programming
some program statements run when triggered by an event, like a mouse click or a key press -Programs run differently each time depending on user interactions
Conditionals
statements that run under only certain conditions (e.g. If, If-Else)
iteration
the repetition of a process like with a for loop or while loop.
List Reduce - smallest number
var mileTimes = [5, 7, 8, 12]; function slow(){ var temp = 0; for(var i=0; i<mileTimes.length; i++){ if(mileTimes[i] > temp){ temp = mileTimes[i]; } } slowest = temp; }
