Chapter 2 & 3 Flashcards

Variables, Assignments, and Branches (44 cards)

1
Q

Define a variable, in a program.

A

It is a names item, such as x or numPeople, used to hold a value.

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

Define an assignment statement.

A

This assigns a variable with a value, such as x=5. This means x is assigned with 5, and x keeps that value during subsequent statements, until x is assigned again. *The assignment’s left side must be a variable. The right side an expression.

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

What is a variable declaration?

A

This declares a new variable, specifying the variable’s name and type.

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

Define integer

A

This is a type of variable, that can hold whole number values, like 1, 999, 0, or -25 (not 3.5)

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

What is an assignment statement?

A

This assigns the variable on the left-side of the ‘=’ with the current value of the right side expression. Ex: numApples = 8

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

Define expression.

A

This may be a number like 80, a variable name like numApples, or a simple calculation like numApples + 1.

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

Define identifiers, in programming.

A

This is a name created by a programmer for an item like a variable or function. *these are case sensitive, meaning upper and lower case letters differ.

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

Define naming conventions.

A

A set of style guidelines defined by a company, team, teacher, etc. for naming variables.

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

What are the two common conventions for distinguishing words in an identifier?

A

Camel case and underscore separated

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

What is a literal, in arithmetic expressions?

A

It is a specific value in code, like 2.

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

What is an operator?

A

It is a symbol that performs a built-in calculation, like ‘+’ which performs addition

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

What is the division operator?

A

/

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

What is a unary minus?

A

It is a minus used as a negative.

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

What is incremental development?

A

It is the process of writing, compiling, and testing a small amount of code, then writing, compiling, and testing a small amount more, and so on.

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

What is a floating-point number?

A

It is a real number like, 98.6, 0.0001, or -666.667. *This term refers to the decimal point being able to appear anywhere in the number “float”.

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

What is the meaning of variable “float”?

A

This is a variable declared as type float, which stores a floating-point number.

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

What is a floating-point literal?

A

This is a number with a fractional part, even if that fraction is 0, as in 1.0, 0.0, 99.573.

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

What is a function?

A

This is a list of statements executed by invoking the function’s name, with such invoking known as a function call.

19
Q

What is “RandomNumber()”?

A

A function is built-in Coral function that takes two arguments, lowValue and highValue and returns a random integer in the range lowValue to highValue.

20
Q

Define “seed”.

A

For the first call to RandomNumber(), no previous random integer exists, so the function uses a built-in integer.

21
Q

What is a type conversion?

A

Is a conversion of one data type to another, such as an integer to a float.

22
Q

What is an implicit conversion?

A

Coral automatically performs several common conversions between integer and float types, and such automatic conversion.

23
Q

Define type cast

A

Converts a value of one type to another type.

24
Q

What is a modulo operator?

A

This operator evaluates to the remainder of the division of two integer operands. Ex: 23 % 10 is 3

25
What is a character?
Is a single letter, like 'A', 'p', or '%'.
26
What is string?
Is a sequence of characters, like "Hello" or "The forecast for today is sunny with highs of 75F."
27
What is boolean?
Refers to a quantity that has only two possible values, true or false.
28
What is an array?
This is an ordered list of items of a given data type, like an array of integers or an array of floats.
29
Define a constant.
It is a named value item that holds a value that cannot change. Ex: pi, the speed of light, or kilograms per pound
30
What is a branch?
It is a sequence of statements only executed under a certain condition.
31
Define "decision".
This creates two branches: If the decision's expression is true, the first branch executes, else the second branch executes.
32
Define "if-else" branches.
A decision and its two branches are often called __ branches, IF the decision's expression is true then the first branch executes, ELSE the second branch executes.
33
Define "if" branch.
A decision whose false branch has no statements
34
Define "if-elseif" branches.
A series of decisions appear cascaded in each decision's false branch, to detect specific values of a variable.
35
Define equality operator.
== evaluates to true if the left and right sides are equal.
36
Define "nested branches".
A branch's statements can include any valid statements, including another if-else branch.
37
Define "multiple if" branches.
Each decision is independent, and thus more than one branch can execute, in contrast to the If-elseif arrangement where only one branch can execute.
38
Different operand
!=
39
What is a logical operator?
This treats operands as being true or false, and evaluates to true or false. Logical operators include and, or, not.
40
Logical and
True when both operands are true
41
Logical or
True when at lease one of the two operands is true
42
Logical not
True when the one operand is false, and vice-versa
43
Define "nested if-else statement/branches"
A branch's statements can include any valid statements, including another if-else statement.
44
What are the valid equality and relational operators?
==, !=, <, <=, >, >=