UNIT 4 Flashcards

covers everything that was taught in U4

1
Q

U4L1 Evaluate

A

+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

U4L1 Can you use the / operator to concatenate?

A

No, only the + operator to concatenate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

U4 L10
What will the statement show after running the code?

KEEP IN MIND: var changes at top of screen, which of the two are displayed?

A

It will display “School day”

sat -> mon, mon != sat or sun so “else”, “else”=weekday, weekday= SD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

U4 L8
What part of the code do you use flowcharts for?

A

if else statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

U4 L8
STATEMENTS
what does the “if” statement do?

A

specifies a block of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

U4 L8
STATEMENTS
what does the “else” statement do?

A

if the same condition is false, it specifies the execution for a block of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

U4 L8
STATEMENTS
what does the “else if” statement do?

A

tests if the first condition is false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

U4L2
how do “getText” and “getNumber” work?

A

grabs the text/number from the chosen line of code

getText (“locationDropdown”) ;
= gets text from locationDropdown

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

U4L3
how many times do you have to create variables and why?

A

once, can cause errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

U4L3
where should you keep your variables and why?

A

at the top of the program to stay organized

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

U4L3
should your variables be created inside or outside a function or onEvent?

A

outside

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

U4L11
if I want the screen to update as I type, in stead of “onEvent(“downButton”, “click”, function( ) {“ what should I write?

A

onEvent(“downButton”, “change”, function( ) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

U4L2
how do I get a users name input to show on the screen output

(ex: they’d type “Jassy” and Jassy would be shown somewhere on screen)

A

getText, (ex:
userName = “Hi, “ + getText(“nameInput”)+”!”;
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

U4L2
how do I get a value of a variable to increase or decrease? (ex: value goes up or down)

A

math (+-)

( ex: tempF = tempF + 1; )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

U4L2
which programs should comments be used in and why?

A

every program, helps the debugging process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

U4L4
where should comments be used, placed, and what should they include?

A

should be used above every onEvent, function, starting variables, and include purpose & purpose

17
Q

U4L4
what does “\n” do?

A

creates a new line of output

18
Q

U4L5
what does a flowchart do?

A

visualizes an if-else statement before using it

19
Q

U4L5
true or false, “ 6+3 == 3+4” ?

20
Q

U4L6
can an expression deal with a “maybe” answer

A

yes, develop a range (ex: 1) yes 2) sometimes 3) no)

21
Q

U4L6
how do u evaluate a percentage?

A

long division

22
Q

U4L6
what does the following if-else statement mean?
“if (score > 15){
setProperty(“lemon”,”width”,60);
setProperty(“lemon”,”height”,60);
} else if (score > 10) {
setProperty(“lemon”,”width”, 100);
setProperty(“lemon”,”height”, 100);
} else {
setProperty(“lemon”,”width”, 140);
setProperty(“lemon”,”height”, 140);
}”

A

if the score is greater than 15 the lemon is set at 60 w&h
if the score is greater than 10 the lemon will increase in size by +40
if-else (is greater than 15) the lemon will increase in size by +40 once again

23
Q

U4L7
what code is used to get a screen to change when a button is clicked

A

onEvent and setScreen

24
Q

U4L8
if I wanted to make a discountCode on something that cost $$$ what should I do?

A

create if-else statement, some kind of math code, and set the price to discount

ex: price=0

25
U4L9 what is myFunction and function? what does it help with?
function: a repeated line of code myFunction: calls the function to a line of code -helps shorten the amount of code without lines being reused -organizes unnecessary added code
26
U4L9 where should a function be placed in code and why?
the bottom of the function to get it out of the way of the rest of the code
27
U4L10 when there is a bug in your program and you don't know what it is, what should you do and why?
get a second set of eyes because it can be a mistake that may go unnoticed for you
28
U4L2 why do id names need to be unique?
so you know exactly what the function is and what it does
29
U4L1 what will the value of "score" be at the end of the program?
"The score is: 4" | just "4" isnt correct, the string "The score is:" mustn go unnoticed
30
U4L2 what is "myVar" first set at and what does the onEvent do?
the myVar first is set with a value of zero. When clicked, the myVar 's current value (0) will add on 1. every time the button is clicked the value will go up by one.
31
U4L3 what will be displayed once the code is ran?
6 | first the value is 2, then set to 5, lastly 5+1, which equals:
32
U4L3 which of the following COULDNT be output from the program? a) 1,1,20,20 b) 2,2,11,11, c) 10,10,10,10 d) 10,5,10,5
d | a= 1-10 a=1-10 b=10-20 b=10-20 last two lines HAVE to be >=10
33
U4L11 what are the steps to creating a dropdown?
1. dropdown in code 2. creating variable 3. "var= get__" | 4. (OPTIONAL) updateScreen (function)
34
U4L11 if I want the size to increase or decrease AS I change it, what part of the code should I change? | ex: onEvent("fontSizeInput", "click", function( ) {
change "click" to input | onEvent("fontSizeInput", "input", function( ) {
35
U4L11 why is it bad to have grey and red as a font color
grey=harder to see red=bad for colorblind people
36
U4L12 if I were to make an app on what to wear based on the weather, what variables should I consider?
time, place, weather, temperature, and event
37
U4L12 how many times should a updateScreen function be called in a program?
ATLEAST two times | there is no point of a function if not called multiple times
38
U4L12 why would a function be used?
to update a screen
39
U4L12 before going straight into coding your program, what should you do first?
design the app