Variables And Assignments Flashcards

1
Q

What does = mean in programming?

A

It assigned a value, IT DOES NOT MEAN EQUALS

X = 5 assigns the value 5 to the variable x

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

What does a variable declaration do?

A

Declares a new variable, specifying the variables name and type.

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

What is a name for a variable or function?

A

Identifier

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

An identifier must:

A

Be a sequence of letters (a-z, A-Z), underscores, and digits
Start with a letter

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

what are reserved words? Give examples

A

Words that are part of the language

Integer, Get, Put

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

List of reserved words:

A

Get
Put
To
From
Input
Output

Integer
Float
Array
And
Or
Not

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

List of reserved function names:

A

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

A combination of items, like variables, literals, operators, and parenthesis that evaluates to value and commonly used on the right side of an assignment statement.

X = 2 * (x + 1)

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

What is a literal?

A

A specific value in code, like ‘2’.

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

What is an operator?

A

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
11
Q

In programming, can multiplication be indicated like this: 2x

A

No, it must be indicated explicitly, 2 * x

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

In y = x + 1, what is the expression?

A

X + 1

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

What is a -minus known as in programming?

A

Unary minus

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

Are commas allowed in an integer general?

A

No

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

What is incremental dev?

A

Process of writing, compiling, and testing a small amount of code, then writing, compiling, and testing a small amount more, and so on.

WCT

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

What is a floating point number?

A

A real number, like 98.6, 0.0001 and refers to the decimal point being able to appear anywhere.

It is a data type that represents a real number with a fractional component.

17
Q

What is a floating point literal?

A

A specific representation of a floating point number as written in a program or source code. It can be a decimal or exponential notation.

It is a specific representation of a value of this data type in a program or source code.

18
Q

What may a floating point variable that holds the value 299792458.0 be printed as?

A

2.99792e+08

19
Q

Floating point variables are used when dealing with _____________.

A

Fractions of countable items, such as the average number of cars per household, avg. distances, and avg. weights

20
Q

By default most programming languages output at ___ digits after the decimal point.

21
Q

Is this a valid function? Why or why not?

Y = SquareRoot (2.0, 8.0)

A

No, because SquareRoot () only accepts one argument.

22
Q

If the growth rate of a tree is 5% per year, what is the float number the program computes?

23
Q

What two arguments does RandomNumber () take?

A

LowValue and highValue

24
Q

What type of number does RandomNumber () return?

A

A random integer in the range lowValue to highValue

25
How is plus one used with RandomNumber (10, 20)?
20 - 10 + 1 which equals 11
26
What does pseudo mean?
Not actually, but having the appearance of.
27
When no previous integer exists for RandomNumber(), what built in integer is used?
Seed
28
When the operands of / are both integers, what is performed?
Integer division
29
What is 10 / 4?
2, not 2.5 because integer division does not generate fractions
30
What is the answer when dealing with integers (5+10) * (1/2)?
0, it will always be 0 because integer division does generate fractions
31
For integer division, what occurs if the second operand of / or % is 0 (zero)?
A divide-by-zero error occurs at runtime, causing a program to terminate
32
What is a defining feature of an integer?
A thing is countable. People in a room, cars in a parking lot, number of births per year.
33
What is a type conversion? Give an example.
Conversion of one data type (integer) to another (float). 25 becomes 25.0 4.9 becomes 4
34
For an equation with + or *, what happens when one of the operands is a float?
The arithmetic operand is automatically converted to a float, then a floating point operation is performed.
35
What does a type cast do?
Converts a value of one type to another type.
36
What does the modulo operator (%) do?
Evaluates to the remainder of the division of two integer operands 23 % 10 is 3
37
Any odd number % 2 equals?
1
38
What is a constant?
A named value whose value cannot change
39
What is a good practice when naming constants?
Using all caps separated by underscores ALL_CAPS