WGU D278 Scripting And Programming
Foundations – Questions With Right Solutions
What is the purpose of a variable? Correct Answer - To store
Data values that can be changed and used later in a program
How do you save a value to a variable? Correct Answer - By
using a assignment statement Ex: X=5
What is a programming expression? Correct Answer - A
combination of variables, literals, and operators that produce a
value
What is an identifier? Correct Answer - The name used to
identify variables functions or other entities in code
What constitutes a valid identifier? Correct Answer - starts
with a letter or underscore followed by letters,digits or underscores
and no spaces or special characters
What is a literal? Correct Answer - A fixed value written
directly in code ex: 42, Hello, 3.14
What is an operator? Correct Answer - A symbol or keyword
that performs operations on variables and values ex +,-,/,*
What precedence rules does programming use? Correct Answer -
Rules that determine the order in which operations are performed,
Ex Parenethesis, Multiplication, addition/subtraction
P
E
M
D
, A
S
How does an integer differ from a float Correct Answer - An
integer is a whole number without a decimal point, while a float is a
number with decimal places
What happens if you divide two integers/ an integer and a float?
Correct Answer - Dividing two integers often results in integer
division (discarding remainder) or float division depending on
language.
Dividing an integer by a float results in a float
What happens if you divide a nonzero floating point number by
zero? Correct Answer - It results in infinity or a runtime error,
depending on the language and environment.
How do you convert an item's type? Correct Answer - By using
type casting functions like int(), float(), or similar.
What does the modulo operator do? Correct Answer - Returns
the remainder after division of one number by another.
What is the difference in a variable and a constant? Correct
Answer - Variables can change values; constants cannot be
changed once set.
How does an array work? Correct Answer - An array stores
multiple values of the same type in a contiguous block of memory,
accessible via indices.
What does index reference? Correct Answer - The position of
an element in an array or list, usually starting at 0.
Foundations – Questions With Right Solutions
What is the purpose of a variable? Correct Answer - To store
Data values that can be changed and used later in a program
How do you save a value to a variable? Correct Answer - By
using a assignment statement Ex: X=5
What is a programming expression? Correct Answer - A
combination of variables, literals, and operators that produce a
value
What is an identifier? Correct Answer - The name used to
identify variables functions or other entities in code
What constitutes a valid identifier? Correct Answer - starts
with a letter or underscore followed by letters,digits or underscores
and no spaces or special characters
What is a literal? Correct Answer - A fixed value written
directly in code ex: 42, Hello, 3.14
What is an operator? Correct Answer - A symbol or keyword
that performs operations on variables and values ex +,-,/,*
What precedence rules does programming use? Correct Answer -
Rules that determine the order in which operations are performed,
Ex Parenethesis, Multiplication, addition/subtraction
P
E
M
D
, A
S
How does an integer differ from a float Correct Answer - An
integer is a whole number without a decimal point, while a float is a
number with decimal places
What happens if you divide two integers/ an integer and a float?
Correct Answer - Dividing two integers often results in integer
division (discarding remainder) or float division depending on
language.
Dividing an integer by a float results in a float
What happens if you divide a nonzero floating point number by
zero? Correct Answer - It results in infinity or a runtime error,
depending on the language and environment.
How do you convert an item's type? Correct Answer - By using
type casting functions like int(), float(), or similar.
What does the modulo operator do? Correct Answer - Returns
the remainder after division of one number by another.
What is the difference in a variable and a constant? Correct
Answer - Variables can change values; constants cannot be
changed once set.
How does an array work? Correct Answer - An array stores
multiple values of the same type in a contiguous block of memory,
accessible via indices.
What does index reference? Correct Answer - The position of
an element in an array or list, usually starting at 0.