Part 3 e): Matplotlib Grouped Bar Chart
· In grouped bar charts, you need to separate x coordinate arrays because each group of bars shares the
same category labels on the x – axis, but the bars themselves must be positioned at different x –
coordinates so they appear side by side rather than on top of each other.
· Using identical x-coordinates would cause bars to overlap completely, making the chart unreadable
· Separate x-coordinate arrays position each dataset's bars side-by-side for clear visual comparison
Mathematical relationship:
The second x-coordinate array(r₂) is calculated based on the first array (r₁) and the bar width using the
formula:
r₂ = r₁ + width
Where width represents the width of each individual bar.
Part 2 e): SymPy Library Fundamentals
Role of sp. symbols () function:
The sp. symbols() function is fundamental in SymPy as it creates symbolic variables that can be
manipulated algebraically rather than storing numerical values. These symbols enable symbolic
mathematics, including equation solving, differentiation, integration, and algebraic simplification.
Solver default behavior:
The main SymPy solver [Link]() automatically assumes that any algebraic expression passed to it
equals zero. For example, [Link](2*x + 3, x) solves the equation 2x + 3 = 0, finding the roots where
the expression equals zero.
Part 1 e): Python Sequence Types - Lists vs Tuples
Primary Difference - Mutability:
The fundamental distinction between lists and tuples lies in their mutability properties:
· Lists are mutable: Elements can be modified, added, or removed after creation
· Tuples are immutable: Once created, elements cannot be changed, added, or removed
Structural Definition:
· Lists are defined using square brackets: my_list = [1, 2, 3]
· Tuples are defined using parentheses: my_tuple = (1, 2, 3)
Practical Examples:
my_list = [1, 2, 3]
my_list [0] = 10 # Valid – modifies the list
my_tuple = (1, 2, 3)
my_tuple [0] = 10 #TypeError: ‘tuple’ object does not support item assignment
This immutability makes tuples useful for fixed data collections, dictionary keys, and generally when you
want to ensure data integrity.