CSC Lesson 2 Flashcards

1
Q

What is an assignment statement?

A

Something that assigns a variable with a value (ex. x = 5)

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

Which side of assignment statement is the variable commonly on?

Which side of the assignment statement is the expression commonly on?

A

The variable is on the left side.

The expression is on the right side.

                                x = w + 2
                (variable)            (expression)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an identifier and what are the rules for how it must be named?

A

An identifier is a name created by a programmer for an item like a variable or a function.

An identifier must:

Be a sequence of letters (a-z, A-Z), underscores (_), and digits (0-9)

It also must start with a letter.

You cannot use a reserved word (keyword) for an identifier.

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

What is a reserved word (keyword)?

A

A reserved word is a word that is part of the language like “integer”, “get”, “put”, “to”, “from”, “input”, “output”, etc.

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

(common conventions for identifiers) Camel Case

A

numApples, pureLeaf, seaSalt, kobeYarnSeason

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

(common conventions for identifiers) Underscore Seperated

A

bring_that_here, jimmer_dropped_forty, we_like_speeding

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

Common Coral Identifiers

A

Get, Put, to, from, input, output

integer, float, array, and, or, not

RaiseToPower, SquareRoot, AbsoluteValue, RandomNumber, SeedRandomNumbers

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

What is an expression?

A

An expression is a combination of items like variables, literals, operators and parentheses that equates to a value.

Commonly on the right side of an assignment statement

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

What is a literal?

A

A literal is a specific value in code, (ex. 2)

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

What is an operator?

A

An operator is a symbol that performs a built in calculation, like the operator + which performs addition.

Common operators:
+ (addition)
- (subtraction)
* (multiplication)
/ (division)

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

(Evaluation of Expressions) Precedence

A

Items in parentheses get evaluated first.

“unary -“ used for negation is next (2* -x) “-x” is evaluated first then multiplied by 2

  • and / have equal precedence

+ and - have equal precedence after * and /

If more than one operator of equal precedence is used evaluation is left to right

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

What is a floating-point number?

A

Floating-point refers to decimal point being able to float anywhere.
96.4, -66.7777, etc.

Always have an integer before decimal so number doesn’t get mistaken.
0.3, 0.643, etc.

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

Coral built-in math functions

A

SquareRoot(x) - SquareRoot(9.0) = 3.0

RaiseToPower(x,y) - x^y

AbsoluteValue(x) - AbsoluteValue(-99.5) = 99.5

RandomNumber() - RandomNumber(1,10) generates random
number between 1 and 10

SeedRandomNumber() - will produce the same sequence of
random numbers

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

What is a function?

A

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

Any function input values, or arguments, appear inside a pair of ()
and are separated by commas if more than one.

-ex. multiply(a,b)

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

explain Integer Division

A

When the operands of / are both integers the output will be an integer and not a fractional (float) number.

10 / 4 will output 2 and not 2.5

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

What is a type conversion?

A

A type conversion is a conversion of one data type to another.

(ex. and integer to a float)

17
Q

What is an implicit conversion?

A

An automatic type conversion in Coral.

If any operand is a float it will output a float.

18
Q

What is a modulo operator? (%)

A

A modulo operator evaluates to the remainder of the division of two integer operands.

(ex. 24 % 10 = 4) because 24 / 10 is 2 with a remainder of 4 left

(ex. 10 % 4.0 is not valid) because remainder only makes sense for integer operands

19
Q

Different data types

A

Integer - A whole number value (1, 2, 3, etc.)

Float - Floating-Point number (-4.323, 0.663, 5.324, 12.453, etc.)

Character - A single letter (R, F, %, e, d, etc.)

String - A sequence of characters (Hello, Goodbye)

Boolean - A quantity that has only two possible values (true or false)

Array - An ordered list of items of a given data type

20
Q

What is a constant?

A

A constant is a named value item that holds a value that cannot change. (pi, speed of light, kilograms per pound, etc.)

Can also be used for values that should not change during the programs execution

21
Q

What is a variable declaration?

A

A variable declaration declares a new variable specifying the variable’s name and type