1/111
Jake P
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What 4 commands does Karel know?
move(); turnLeft(); putBall(); takeBall();
Dissect a Karel command.
-No spaces in commands -Need to match exact capitalization - Every command ends in ();
What is a street in Karel's world?
A street is a row in Karel's world
What is an avenue in a Karel world?
An avenue is a column in Karel's world
How can we make Karel turn right, even though Karel doesn't know a turn right command?
We can create a turnRight function and have Karel turn left three times
Why are functions useful?
They allow programmers to reuse repeatable code, and help make code more readable and efficient
Why should the name of the function describe WHAT the function does?
Programs are written in code not just for computers to read but for other people, too!
The name of the function should sound like a command and start with an …
Action verb
How do you write a multi-line comment?
/ *
*
How do you write a single-line comment?
//
What are preconditions?
What assumptions we make and what must be true BEFORE the function is called
What are postconditions?
What should be true AFTER the function is called
What is the difference between Karel and Super Karel?
turnRight(); and turnAround(); are already defined in super Karel
Explain For Loops.
For Loops let us repeat a section of code a fixed number of times
What is a condition?
A condition is a function that returns a true/false answer
Why do we use if statements in JavaScript?
To do something only if a condition is true
What is the difference between if statements and if/else statements?
With the if statement, a program will execute the true code or do nothing. With the if/else statement, the program will execute either the true code block or the false code block so something is always executed with an if/else statement
What does an if/else statement look like in JavaScript?
if (condition) {
// code
} else {
// code
}
What does the command console.log do?
JavaScript function that prints out a line to the user
Explain what variables are and what they are used for.
Variable means anything that can vary. It stores the data value that can be changed later on
What are the three functions that we can use to get user input?
readLine
readInt
readFloat
Describe the different mathematical operators we can use in programs.
Addition +
Subtraction -
Multiplication *
Division /
Exponentiation **
Modulus %(divide and take the remainder)
What is the drivers role AND the navigator's role when pair programming?
The driver's role is to control the computer and focus on the task at hand. The navigator's role is to review the code and think of strategic alternatives
Explain why random numbers are a useful part of computer programs.
To make our programs more interesting
What are the three steps to add objects?
What happens when you set debug mode to true?
The program lets you see a red frame around the shape of the object and a bold red point at the anchor point
What can you add to the canvas besides shapes?
Where should you put a URL for an image?
You should store it inside of a constant (const)
Explain the purpose of getWidth() & getHeight().
They return the width & the height of the canvas
To position a circle at the center of the canvas what should the circle's x AND y coordinates be set to?
getWidth()/2, getHeight()/2
What are booleans?
Refers to a value that is either true or false
Who are Booleans named after?
George Boole
(mathematician, philosopher, logician, one of the founders of computer science)
Describe the meaning and usage of the OR Operator (||).
OR (||): The operator which would return the value TRUE or Boolean value of 1 if either or both of the operands are TRUE or have a Boolean value of 1
Describe the meaning and usage of the AND Operator (&&).
AND (&&): The operator returns a value of TRUE if both its operands are TRUE, and FALSE otherwise
Describe the meaning and usage of the NOT Operator (!).
NOT (!): The operator reverses the logical value associated with the expression it operates
Explain the meaning of this comparison operator (<).
Explain the meaning of this comparison operator (<=).
Explain the meaning of this comparison operator (>).
Returns true if the value on the left is greater than the value on the right, otherwise it returns false
Explain the meaning of this comparison operator (>=).
= Returns true if the value on the left is greater than or equal to the value on the right, otherwise it returns false
Explain the meaning of this comparison operator (==).
== Returns true if the value on the left is equal to the value on the right, otherwise it returns false
Explain the meaning of this comparison operator (!=).
!= Returns true if the value on the left is not equal to the value on the right, otherwise it returns false
Karel
A dog who listens to your commands.
World
A grid that Karel lives in.
lowerCamelCase
A naming convention where the first letter is lower case, and each subsequent start of a word is upper case.
Command
An instruction you can give to Karel.
Move();
Moves Karel one spot in the direction that he's facing.
turnLeft();
Rotates Karel 90 degrees to the left.
putBall();
Adds one ball in spot that Karel is at.
takeBall();
Removes one ball in the spot that Karel is at.
Walls
All of the edges in Karel's world; barriers that Karel is at.
Functions
A way to teach Karel a new command.
Define a Function
To teach the computer a new command and explain what it should do when receiving that command.
Call a Function
Actually giving the command, so the computer will run the code for that function
Main function
This is the function that is called when you click run.
Top Down Design
A method for breaking our program down into smaller parts.
Decomposition
Breaking your program into smaller parts.
Read Like a Story
Programs that have good decomposition and make the code easy to follow.
Programming Style
The way your code is written is the style. It covers the aspects of the code that goes beyond whether or not it just works.
Comment
A message in your code that explains what is going on.
API
A set of words for building software.
Super Karel
Like Karel but already knows how to turnRight() and turnAround().
For Loop
Let us repeat code a fixed number of times.
Conditional
A function that returns a true or false answer.
If Statement
Lets you ask a question to the program and only run code if the answer is true.
If/Else Statement
Control structure that lets us do either one section of code or another depending on a test.
While Loop
Lets us repeat code as long as something is true.
Indentation
The visual structure of how your code is laid out. It uses tabs to organize code into a hierarchy.
Hello World
Traditionally the very first program you write when learning a programming language.
console.log
JavaScript function that prints out a line to the user.
Variable
A symbol or container that holds a value.
Declare a Variable
Defining a variable for the first time.
Intialize a Variable
Giving the variable on initial value.
Number Variable
Integers (positive or negative whole numbers) and Floats (numbers that have a decimal).
Boolean Variable
Has a variable that is either true or false.
String Variable
Stores text. String concatenation is combining strings in JavaScript
readLine
Allows for the reading of user input when a string is used.
readInt
Allows for the reading of user input when an integer is used.
readFloat
Allows for the reading of user input when a decimal number is used.
Modulus
Returns the remainder of a dividing two numbers (%).
Increment
Increase the value of a variable by 1.
Decrement
Decrease the value of a variable by 1.
Constant
In programming, a variable that's value can not be changed through reassignment.