Lesson 2 Questions | Programming Fundamentals
• What is the purpose of a variable?
variable is a named item, such as x or numPeople, used to hold a value
other examples include: age, name, height, or total
• How do y
...
Lesson 2 Questions | Programming Fundamentals
• What is the purpose of a variable?
variable is a named item, such as x or numPeople, used to hold a value
other examples include: age, name, height, or total
• How do you save a value to a variable?
Value is assigned to a value by using “=” example z = w + 2
• What is a programming expression?
expression is a combination of items, like variables, literals, operators, and parentheses,
that evaluates to a value.
assignment statement assigns a variable with a value, such as x = 5
assignment statement contains the following :
(variable) = (expression) This would combined variable and expression
• What is an identifier?
Identifier – a label created by a programmer for an item such as a function or variable
• What constitutes a valid identifier?
1. Be a sequence of letters, underscores, and digits
2. Must start with a letter
3. Identifiers are case sensitive
• What is a literal?
Literal = specific values like 2 or 5.79
• What is an operator?
Operator = think ‘operation’ are examples of symbols that represent arithmeticCategories of Operators:
Summary
• Arithmetic Operators: Perform mathematical calculations.
• Relational Operators: Compare values and return boolean results.
• Logical Operators: Perform logical operations on boolean values.
• Assignment Operators: Assign values to variables and modify them.
• Bitwise Operators: Perform operations on the binary representations of integers.
Sometimes the most confusing is = vs == as they are in different operatiors
• What precedence rules does programming use?precedence rules – similar to PEDMAS in arithmetic, dictate the order of operations; In
this case of something has equal preference than it is based on left-to-right rules. Modulo
has equal precedence to division and multiplication.
• How does an integer differ from a float?
integer – holds whole number values
floating-point number is a real number, like 98.6, 0.0001, or -666.667
floating-point literal is a number with a fractional part, even if that fraction is 0, as in 1.0,
0.0, or 99.573
• What happens if you divide two integers? A integer and float?
Dividing by two integers, if the first is smaller than the second than it will end up 0 as an
integer. If it is float then it will include decimal places. Example 10/12 = 0 for integer but
would be 0.83 (longer depending on the number of allowable decimal places)
• What happens if you divide a nonzero floating point number by
zero?
In Coral, dividing floating point by zero does not give an error, it gives e
[Show More]