Page 108 - KEC Khaitan C8 Flipbook
P. 108

Output
                   Original list: [3, 1, 4, 1, 5, 9, 2, 6]
                   Length of list (len): 8
                   Converted tuple to list (list): [10, 20, 30]
                   Maximum value in list (max): 9
                   Minimum value in list (min): 1
                   Sum of list items (sum): 31
                   Sorted list (sorted): [1, 1, 2, 3, 4, 5, 6, 9]
                   Reversed list (reversed): [6, 2, 9, 5, 1, 4, 1, 3]
                   After appending 7 (append): [3, 1, 4, 1, 5, 9, 2, 6, 7]
                   After extending with [8, 9] (extend): [3, 1, 4, 1, 5, 9, 2, 6, 7, 8, 9]
                   After inserting 0 at index 0 (insert): [0, 3, 1, 4, 1, 5, 9, 2, 6, 7, 8, 9]
                   After removing first occurrence of 1 (remove): [0, 3, 4, 1, 5, 9, 2, 6, 7, 8, 9]
                   Popped item at index 3 (pop): 1
                   List after pop(3): [0, 3, 4, 5, 9, 2, 6, 7, 8, 9]
                   After clearing the list (clear): []







                            SOME MORE PROGRAMS

                  Program 16: To calculate the area of different shapes

                      Program16.py
                   File  Edit  Format    Run   Options   Window    Help

                   def calculate_area(name):
                       name = name.lower()
                       if(name == 'rectangle'):
                           l = float(input('Enter the length of the rectangle: '))
                           b = float (input('Enter the breadth of the rectangle: '))
                           rect_area = 1 * b
                           print('The area of the rectangle is: ', rect_area)
                       elif(name == 'square'):
                           s = float(input('Enter the side of the square: '))
                           sqr_area = s * s
                           print('The area of the square is:', sqr_area)
                       elif (name == 'circle'):
                           pi = 3.14
                           r = float(input('Enter the radius of the circle: '))
                           circle_area = pi * r**2
                           print('The area of the circle is: ', circle_area)
                       else:
                           print('sorry! This shape is not available')
                   print('Calculate Area for: Rectangle, Square, or Circle')
                   shape_name = input('Enter the name of the shape whose area you want to find: ')
                   calculate_area(shape_name)








                  106   Premium Edition-VIII
   103   104   105   106   107   108   109   110   111   112   113