Page 272 - CTS - CSA TP - Volume 2
P. 272

COMPUTER SOFTWARE APPLICATION - CITS




           Output:










           TASK 4: Nested Lists

           # Creating a nested list
           matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
           # Accessing elements in a nested list
           print(matrix[1][2])  # Output: 6
           Output:













           TASK 5: List Method
           # Creating a list
           my_list = [10, 20, 30, 40]
           # Using list methods
           my_list.append(50)      # Appending an element

           my_list.remove(20)      # Removing an element
           popped_value = my_list.pop()  # Popping and retrieving the last element
           # Displaying the modified list
           print(“Modified List:”, my_list)
           Output:













           TASK 6: Maximum and Minimum
           # Creating a list of numbers
           numbers = []

           limit=int(input(“Enter the Limit: “))
           foriin range(0,limit):
           numbers.append(int(input(“Enter the Numbers: “)))




                                                           257
 CITS : IT & ITES - Computer Software Application - Exercise 128  CITS : IT & ITES - Computer Software Application - Exercise 128
   267   268   269   270   271   272   273   274   275   276   277