Comprehensive Solutions
What is the purpose of a variable? Correct Answer - to hold
value
How do you save a value to a variable? Correct Answer - Use
an Assignment statement such as x=5
What is an identifier? Correct Answer - A name created by a
programmer for an item like a variable or function.
What is a programming expression? Correct Answer - is a
combination of items, like variables, literals, operators, and
parentheses, that evaluates to a value
What constitutes a valid Identifier? Correct Answer - must be a
sequence of letters (a-z, A-Z), underscores (_), and digits (0-9)
start with a letter
What is a literal? Correct Answer - A literal is a specific value
in code, like 2
What is an operator? Correct Answer - is a symbol that
performs a built-in calculation, like the operator + which performs
addition.
What precedence rules does programming use? Correct Answer -
( ) parentheses
unary - negation
* / multiplication/ division
+ - addition/Subtraction
Left to Right
, How does an integer differ from a float? Correct Answer -
Integer=Whole Numbers
Float=Numbers with decimals
What happens if you divide two integers? Correct Answer - the
solution will be an integer no decimal points used (use integer
division)
What happens if you divide an integer and a float? Correct Answer
- (uses floating point division)
What happens if you divide a nonzero floating point number by
zero? Correct Answer - divide-by-zero error and the program
terminates.
How do you convert an item's type? Correct Answer - If either
is a float the other is converted to a float
For assignments, the right side type is converted to the left side type
integer-to-float conversion is straightforward: 25 becomes 25.0.
float-to-integer conversion just drops the fraction: 4.9 becomes 4.
Type casting Ex: If myIntVar is 7, then myIntVar * 1.0 converts
integer 7 to float 7.0.
What does the modulo operator do? Correct Answer -
evaluates to the remainder of the division of two integer operands.
Ex: 23 % 10 is 3.
What is the difference in a variable and a constant? Correct
Answer - A constant is a named value item that holds a value that
cannot change.
Variable value changes