Foundations of Coding Excellence
1. Describe the significance of statements in the structure of a program.
Statements are used to define data types in a program.
Statements are essential as they represent individual instructions
that the program executes, each on its own line.
Statements are a way to group multiple functions together.
Statements are only relevant in error handling.
2. Code that results in a value is called a(n) ___________
expression
declaration
definition
statement
3. What is a common word for the textual representation of a program?
Interpreter
Prompt
Expression
Code
4. What is a type error in programming?
A syntax error occurs in the code.
An operation uses incorrect types.
A variable is not defined before use.
,A function is called with the wrong number of arguments.
,5. What does the find(x) function return when applied to a string?
The last occurrence of x in the string
The index of the first occurrence of x in the string
A boolean value indicating if x is present in the string
The total number of occurrences of x in the string
6. Describe the role of an expression in programming and how it differs
from a statement.
An expression evaluates to a value, while a statement performs
an action.
An expression is a collection of statements, while a statement is a
single line of code.
An expression is a type of variable, while a statement is a function.
An expression is always a number, while a statement can be any
code.
7. If a programmer encounters a name error while running their code, what
steps should they take to resolve the issue?
Increase the memory allocation for the program to prevent errors.
Review the algorithm for logical errors unrelated to variable
definitions.
Reinstall the programming environment to fix potential bugs.
Check the variable names for typos and ensure all variables are
properly defined before use.
8. Which of the following lines of Python code would print out the words
"Introduction to Python" on the screen?
print("Introduction to Python")
PRINT("Introduction to Python")
, PRINT(Introduction to Python)
print(Introduction to Python)
9. If a programmer needs to calculate the average of three decimal
numbers, which data type should they use to ensure accuracy in their
calculations?
string
boolean
float
integer
10. Describe the relationship between arguments and parameters in the
context of a function in programming.
Parameters are the values that functions return after execution.
Arguments define the structure of a function, while parameters
are the values it can accept.
Parameters are the values that are printed by a function.
Arguments are the actual values passed to a function's
parameters when the function is called.
11. Describe a scenario in which a type error might occur in Python.
A type error might occur when trying to add an integer to a
string.
A type error might occur when a function is defined without a
return statement.
A type error might occur when a variable is not initialized.
A type error might occur when using a loop incorrectly.