Variables And Assignments Flashcards
What does = mean in programming?
It assigned a value, IT DOES NOT MEAN EQUALS
X = 5 assigns the value 5 to the variable x
What does a variable declaration do?
Declares a new variable, specifying the variables name and type.
What is a name for a variable or function?
Identifier
An identifier must:
Be a sequence of letters (a-z, A-Z), underscores, and digits
Start with a letter
what are reserved words? Give examples
Words that are part of the language
Integer, Get, Put
List of reserved words:
Get
Put
To
From
Input
Output
Integer
Float
Array
And
Or
Not
List of reserved function names:
RaiseToPower
SquareRoot
AbsoluteValue
RandomNumber
SeedRandomNumbers
What is an expression?
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)
What is a literal?
A specific value in code, like ‘2’.
What is an operator?
A symbol that performs a built-in calculation, like ‘+’ which performs addition.
In programming, can multiplication be indicated like this: 2x
No, it must be indicated explicitly, 2 * x
In y = x + 1, what is the expression?
X + 1
What is a -minus known as in programming?
Unary minus
Are commas allowed in an integer general?
No
What is incremental dev?
Process of writing, compiling, and testing a small amount of code, then writing, compiling, and testing a small amount more, and so on.
WCT
What is a floating point number?
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.
What is a floating point literal?
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.
What may a floating point variable that holds the value 299792458.0 be printed as?
2.99792e+08
Floating point variables are used when dealing with _____________.
Fractions of countable items, such as the average number of cars per household, avg. distances, and avg. weights
By default most programming languages output at ___ digits after the decimal point.
5 (five)
Is this a valid function? Why or why not?
Y = SquareRoot (2.0, 8.0)
No, because SquareRoot () only accepts one argument.
If the growth rate of a tree is 5% per year, what is the float number the program computes?
1.05
What two arguments does RandomNumber () take?
LowValue and highValue
What type of number does RandomNumber () return?
A random integer in the range lowValue to highValue
How is plus one used with RandomNumber (10, 20)?
20 - 10 + 1 which equals 11
What does pseudo mean?
Not actually, but having the appearance of.
When no previous integer exists for RandomNumber(), what built in integer is used?
Seed
When the operands of / are both integers, what is performed?
Integer division
What is 10 / 4?
2, not 2.5 because integer division does not generate fractions
What is the answer when dealing with integers (5+10) * (1/2)?
0, it will always be 0 because integer division does generate fractions
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
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.
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
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.
What does a type cast do?
Converts a value of one type to another type.
What does the modulo operator (%) do?
Evaluates to the remainder of the division of two integer operands
23 % 10 is 3
Any odd number % 2 equals?
1
What is a constant?
A named value whose value cannot change
What is a good practice when naming constants?
Using all caps separated by underscores
ALL_CAPS