Untitled Deck Flashcards
What are user-defined data types?
User-defined data types are defined by a programmer within a program, enabling the creation of variables associated with them.
What are the two types of user-defined data types?
- Non-composite: Enumerated (enum), Pointers
- Composite: Set, Record, Class/object
What is an enumerated data type?
An enumerated data type is defined by listing all possible values, which are specified by the programmer.
What is the pseudocode syntax for defining an enumerated type?
TYPE <identifier> = (value_1, value_2, value_3, etc.)</identifier>
Provide an example of an enumerated type for months.
TYPE TMonth = (January, February, March, April, May, June, July, August, September, October, November, December)
What is the significance of the order in enumerated types?
The order can be used in comparisons and calculations, such as determining if a day is a weekend.
How can values be assigned to enum members?
Values can be assigned by creating constants, e.g., TYPE TPoints = (Win 3, Loss 0, Draw 1).
What is the Python syntax for creating an enumeration?
from enum import Enum
class Color(Enum):
Red=1
Green=2
Blue=3
What is a pointer?
A pointer is a data type whose value refers directly to another value stored in memory, using its address.
What is the pseudocode syntax for defining a pointer?
TYPE <pointer> = ^ <Typename></Typename></pointer>
What is a set in programming?
A set is a composite data type that can store multiple data items in a single variable, following the mathematical concept of a finite set.
What is the pseudocode syntax for defining a set?
TYPE <set-identifier> = SET OF <BaseType></BaseType></set-identifier>
Provide an example of a set definition in pseudocode.
TYPE alphaLetters = SET OF CHAR
DEFINE vowel (‘a’, ‘e’, ‘i’, ‘o’, ‘u’) : alphaLetters
What are the characteristics of a set?
Sets are unordered, unchangeable, unindexed, and do not allow duplicate values.