1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is the difference between definitions written as procedures and ones written as functions?
Functions
Purpose: To calculate or update a value.
Key Command: Must have a return statement.
How to Call: Called inside another statement (like print() or an assignment).
Procedures
Purpose: To perform repetitive actions.
Key Command: Does NOT have a return statement.
How to Call: Called as a standalone statement on its own line.
What are functions used in coding?
They are designed to calculate a value or update a variable.
What should be included in a function?
It must include a return statement to send data back to the part of the program that called it.
What are procedures in coding?
They are used to perform repetitive actions where they do not have a return statement. A procedure is usually called as a standalone statement on its own line.
What are parameters in coding?
They are used to pass information from the main program into a subprogram (such as a function or procedure).
Why should we use parameters?
It allows a subprogram to be used in many different contexts. Instead of relying on hard-coded values or specific global variable names, the subprogram performs its task using whatever data is passed into its parameters at that moment.
What are exceptions in coding?
It is a signal that an error or other unusual condition has occurred.
What are exceptions used for in coding?
To test code for runtime errors and prevent the program from crashing unexpectedly.
What are finally statements used for?
It is an optional clause that is not often used, but when included it always executes whether an error occurred or not.
What are else statements used for?
This optional clause runs only if no error or exception occurs in the try block.