Phase 4 - Level 4: Aggregation & Comparison
Compare arrays, merge arrays, find common elements.
10 programs · open one, then the next
Start with Compare Arrays (Same Order)- 01Compare Arrays (Same Order)IntermediateCompare two Python lists with order-sensitive equality. Students read separate sizes and see why matching values alone are not enough when positions differ.Open example →py# Take first array n1 = int(input("Enter size of first array: ")) arr1 = [] for i in range(n1):
- 02Compare Arrays (Ignore Order)IntermediateCompare list contents while ignoring order using sorted. Students preserve duplicate counts and distinguish sorted-copy equality from comparing sets of values.Open example →py# Take arrays n1 = int(input("Enter size of first array: ")) arr1 = [] for i in range(n1):
- 03Merge Two ArraysIntermediateMerge two lists by concatenation. Students follow input collection and understand why combining sequences does not sort values or remove repeated entries.Open example →py# Take first array n1 = int(input("Enter size of first array: ")) arr1 = [] for i in range(n1):
- 04Find Common ElementsIntermediateFind distinct values shared by two lists. Students combine membership with duplicate suppression and preserve first-list order in the common-value result.Open example →py# Take arrays n1 = int(input("Enter size of first array: ")) arr1 = [] for i in range(n1):
- 05Elements in A Not in BIntermediateFind distinct values present in list A but absent from B. Students trace Python membership checks, directional difference, and first-appearance ordering.Open example →py# Take arrays n1 = int(input("Enter size of first array: ")) arr1 = [] for i in range(n1):
- 06Count Common ElementsIntermediateCount distinct common values with set intersection. Students distinguish shared value types from matching positions and repeated occurrences in either input list.Open example →py# Take arrays n1 = int(input("Enter size of first array: ")) arr1 = [] for i in range(n1):
- 07Element-wise SumIntermediateAdd corresponding entries of two equal-sized lists. Students use a common index and compare element-wise addition with concatenating the lists themselves.Open example →py# Take arrays n = int(input("Enter array size: ")) arr1 = [] for i in range(n):
- 08Element-wise ProductIntermediateMultiply corresponding values of two equal-sized lists. Students pair indexes, append products, and distinguish element-wise multiplication from list repetition.Open example →py# Take arrays n = int(input("Enter array size: ")) arr1 = [] for i in range(n):
- 09Frequency ArrayIntermediateBuild and display a frequency dictionary for integer list values. Students use get with a default and sort dictionary items for predictable numeric output.Open example →py# Take array n = int(input("Enter array size: ")) arr = [] for i in range(n):
- 10Elements Appearing More Than OnceIntermediateList values that occur more than once using a frequency dictionary. Students count first, filter second, and print each repeated value only once in the result.Open example →py# Take array n = int(input("Enter array size: ")) arr = [] for i in range(n):