Python_Programming_Exam_Solutions_with_Section_C
Python_Programming_Exam_Solutions_with_Section_C
- Definition: A list in Python is an ordered, mutable collection of elements that can store items of different data types.
- Characteristics: Lists are indexed and support slicing. Elements can be added, removed, or modified.
- Definition: A variable is a name given to a memory location that stores data. Variables in Python are dynamically typed,
- Characteristics: Variable names can contain letters, numbers, and underscores, but cannot start with a number and are
case-sensitive.
- Example: x = 5
- Definition: Reserved words or keywords in Python have predefined meanings and cannot be used as variable names
or identifiers.
- Definition: A dictionary is a collection of key-value pairs, where each key is unique and maps to a value.
- Characteristics: Defined using curly braces {}. Keys are unique and immutable.
- Definition: Type coercion is the implicit conversion of one data type to another, such as automatically converting an
What is function?
- Definition: A function is a reusable block of code that performs a specific task. It is defined with the def keyword.
- Definition: Data streams are sequences of data used for input and output, such as reading from files or network
communication.
What is Class?
- Definition: A class is a blueprint for creating objects, defining properties and methods to model real-world concepts.
- Definition: Inheritance allows a class to acquire attributes and methods from another class, facilitating code reuse.
- Definition: A tuple is an immutable, ordered collection in Python used to store related data.
- Characteristics: Defined with parentheses (). Elements cannot be modified, added, or removed once created.
- Advantages: Tuples are faster than lists and are hashable, making them suitable as dictionary keys.
- numbers = [3, 1, 4, 2]
- Program to calculate and print the average grades for each student:
- dir(): Lists all attributes and methods available for an object or module.
- Definition: A list in Python is an ordered, mutable collection of elements that can store items of different data types.
- Characteristics: Lists are indexed and support slicing. Elements can be added, removed, or modified.
- Definition: A variable is a name given to a memory location that stores data. Variables in Python are dynamically typed,
- Characteristics: Variable names can contain letters, numbers, and underscores, but cannot start with a number and are
case-sensitive.
- Example: x = 5
- Definition: Reserved words or keywords in Python have predefined meanings and cannot be used as variable names
or identifiers.
- Definition: A dictionary is a collection of key-value pairs, where each key is unique and maps to a value.
- Characteristics: Defined using curly braces {}. Keys are unique and immutable.
- Definition: Type coercion is the implicit conversion of one data type to another, such as automatically converting an
What is function?
- Definition: A function is a reusable block of code that performs a specific task. It is defined with the def keyword.