1/74
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Code
A way to conveying info as symbols
Code is just ______ that have meaning when read in a _______ way
symbols, predefined
Program/Software
Computer-readable code
Types of code (5)
color code
genetic code
morse code
natural language
computer program
In order for us to give computers instructions, we need to to provide instructions in a __________ ___________.
programming language
Each key and mouse click generates a unique _______ (input) that gets sent to the computer. A program then processes the _______ to figure out what to do with them. The program then outputs more ________ that tell the computer to do certain things.
number(s)
All numbers sent as inputs and output to and from a computer are represented using ____ and _____.
0s and 1s
A special program called the compiler takes care of converting our _________ into the ...
program, binary machine code
At a high level, computer programs really just implement ___________
algorithms
Algorithm
A self-contained, step by step set of instructions to solve a problem
_________ implement algorithms
programs
Programs put algorithms into a _______ _________ form
computer executable
How to print "Hello World"
A ________ is like a box that can hold a value
variable
Declaring a variable
(does not enter a value into the variable)
Initializing a variable
Declares a variable and sets its initial value
Assigning to a variable
Changing a variable's value
Types of Variables
Number
Boolean
String
Numeric Variables - Integers
Whole numbers
Numeric Variables - Floats
Real numbers (can be decimals)
Boolean Variables
true/false
String Variable
Text (goes between quotes)
Variable names start with... (3)
a letter
$
_
Variables Example
Functions used to receive user inputs
Use readLine to get/read ... from the user
strings of text
Use readInt to get/read ____ from the user
integers
Use readFLoat to get/read ____ from the user
floats (real numbers)
User input Example
Arithmetic Operators in JavaScript
When a modulus operator is used, it...
divides the two numbers and takes the remainder
Math in JavaScript Example #1
Shortcut for adding and subtracting 1 from a variable
How is the coordinate system oriented for the programming canvas?
The function ____________ gets the width of the canvas
getWidth()
The function ____________ gets the height of the canvas
getHeight()
How to make text located at a certain location
How to make a circle centered at a certain location
How to make a rectangle located at a certain location
When setting the position of rectangles, the position is set at the ________________ of the graphic
top left corner
When setting the position of text, the position is set at the ________________ of the graphic
bottom left corner
Graphics example (8 ball)
Mouse event
When the user does something with the mouse, like clicking or moving
To respond to a mouse click, we use _______ functions
callback
Callback function
A function passed as a parameter to another function in order to be called later. (drawCircle)
When the mouse is clicked, whatever function was passed to ____________ is called
mouseClickMethod
e is an __________ ___________ and can be any variable. We may sometimes use the variable ____________
input parameter, event
e stores information about ...
a mouse/key event
To get the x ant y positions of a click, use...
Click to add a circle example
Key Event Functions
Functions to detect which key is pressed
Moving graphic with keys
What is the proper function to call to print to the screen?
println
What keyword do you need to use to define a variable in JavaScript?
var
What function do you need to call to ask the user of the program to enter text?
readLine
To ask the user of the program for a number, which function should you use?
Both readInt and readFloat are for numbers.
Question in image
What is your name? Karel
Hello Karel
Question in image
Welcome! ¡Hola! ¡Hola! Bonjour!
Question in image
Enter a character. P
: c P
What will the following code print to the screen?
println(2 + 2);
4
What symbol do you use to do division in JavaScript?
/
What symbol do you use to do multiplication in JavaScript?
*
29
4
10
2
Suppose we've written a function drawCircle that we want to call every time the mouse is clicked. How can we do this?
mouseClickMethod(drawCircle);
function start(){
keyDownMethod(animate);
}
Why are computer programs an example of code?
Computer programs are an example of code because programmers use the different programming languages as predefined symbols to communicate with a computer.
Interactive
allowing the flow of information both ways between a computer and its user (with inputs and outputs)
Why is it important for computer programs to display information to users?
It is important for computer programs to display information to users so that the users are aware of the effects of their inputs and the status of either themselves or the computer. For example, it is important for there to be an error message when a user logs in incorrectly so that the user knows that they are not able to gain access because their username/password is wrong.
Why might variables be useful in our programs?
Variables might be useful in our programs to store certain values and allow the values to be easily referenced/recalled later in the program using the variable names
Why is it useful for programs to be able to accept user input?
It is useful for programs to be able to accept user input so the user can both access their personal information/account and so the user can have a personalized experience within the application. For instance, a person enters their login information into a program in order to access their account within the application.
Why is it useful for programs to be able to perform mathematical computations?
It is useful for programs to be able to perform mathematical computations so that the human using the program does not have to waste time calculating the answer themself or lack confidence in the accuracy of their answer since the computer solves the computation much quicker and more accurately. (Math computation programs are especially useful when the math calculation is complex and/or time consuming.)