Trong Python, một bộ là một bộ sưu tập các loại dữ liệu không có thứ tự có thể sử dụng được, có thể thay đổi và không có các yếu tố trùng lặp. Thứ tự của các phần tử trong một bộ không được xác định mặc dù nó có thể bao gồm các yếu tố khác nhau. Ưu điểm chính của việc sử dụng một bộ, trái ngược với danh sách, là nó có một phương pháp tối ưu hóa cao để kiểm tra xem một phần tử cụ thể có chứa trong tập hợp hay không.Set is an unordered collection of data types that is iterable, mutable and has no duplicate elements. The order of elements in a set is undefined though it may consist of various elements. The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for checking whether a specific element is contained in the set. Show
Tạo một bộCác bộ có thể được tạo bằng cách sử dụng hàm tập hợp () tích hợp với một đối tượng có thể lặp lại hoặc một chuỗi bằng cách đặt chuỗi bên trong niềng răng xoăn, được phân tách bằng một dấu phẩy.set() function with an iterable object or a sequence by placing the sequence inside curly braces, separated by a ‘comma’.
Python3Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}0____11 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}3 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}6 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 ____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}8 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}2 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}0____11 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}8 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial set {'For', 'Geeks'} Elements of set: For Geeks True1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 ____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Initial set {'For', 'Geeks'} Elements of set: For Geeks True8 Initial set {'For', 'Geeks'} Elements of set: For Geeks True9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0____51 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial set {'For', 'Geeks'} Elements of set: For Geeks True9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Đầu ra Initial blank Set: set() Set with the use of String: {'e', 'r', 'G', 's', 'F', 'k', 'o'} Set with the use of an Object: {'e', 'r', 'G', 's', 'F', 'k', 'o'} Set with the use of List: {'Geeks', 'For'} Một tập hợp chỉ chứa các phần tử duy nhất nhưng tại thời điểm tạo tập hợp, nhiều giá trị trùng lặp cũng có thể được truyền. Thứ tự của các phần tử trong một bộ không được xác định và không thể thay đổi. Loại phần tử trong một tập hợp không cần phải giống nhau, các giá trị loại dữ liệu hỗn hợp khác nhau cũng có thể được chuyển cho tập hợp. & NBSP; Python3Các Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 The FrozenSet is: frozenset({'o', 'G', 'e', 's', 'r', 'F', 'k'}) Empty FrozenSet: frozenset()5 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 ____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Initial set {'For', 'Geeks'} Elements of set: For Geeks True8 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}7 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__97____ Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__101 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}09 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Đầu ra Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'} Một tập hợp chỉ chứa các phần tử duy nhất nhưng tại thời điểm tạo tập hợp, nhiều giá trị trùng lặp cũng có thể được truyền. Thứ tự của các phần tử trong một bộ không được xác định và không thể thay đổi. Loại phần tử trong một tập hợp không cần phải giống nhau, các giá trị loại dữ liệu hỗn hợp khác nhau cũng có thể được chuyển cho tập hợp. & NBSP;Python3Các Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}23 ____10Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2Initial set {'For', 'Geeks'} Elements of set: For Geeks True8Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}5Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}7Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__97____Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}9Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__101Tạo một tập hợp với một phương thức khácSet with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}13___add() function. Only one element at a time can be added to the set by using add() method, loops are used to add multiple elements at a time with the use of add() method.
Python3Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}0____11 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}3 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}6 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}34 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}35 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}34 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}38 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}40 Initial set: {1, 2, 3, 4, 5} Set after clearing all the elements: set()9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}43 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}44 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}47 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 ____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}60 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}61 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}64 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Đầu ra Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9} Một tập hợp chỉ chứa các phần tử duy nhất nhưng tại thời điểm tạo tập hợp, nhiều giá trị trùng lặp cũng có thể được truyền. Thứ tự của các phần tử trong một bộ không được xác định và không thể thay đổi. Loại phần tử trong một tập hợp không cần phải giống nhau, các giá trị loại dữ liệu hỗn hợp khác nhau cũng có thể được chuyển cho tập hợp. & NBSP;Các Python3____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Initial set {'For', 'Geeks'} Elements of set: For Geeks True8 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}7 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__97____ Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__101 Tạo một tập hợp với một phương thức khác Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}87 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Đầu ra Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11} Một tập hợp chỉ chứa các phần tử duy nhất nhưng tại thời điểm tạo tập hợp, nhiều giá trị trùng lặp cũng có thể được truyền. Thứ tự của các phần tử trong một bộ không được xác định và không thể thay đổi. Loại phần tử trong một tập hợp không cần phải giống nhau, các giá trị loại dữ liệu hỗn hợp khác nhau cũng có thể được chuyển cho tập hợp. & NBSP;Các Python3____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Initial set {'For', 'Geeks'} Elements of set: For Geeks True8 Initial set {'For', 'Geeks'} Elements of set: For Geeks True9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0____51 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial set {'For', 'Geeks'} Elements of set: For Geeks True9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}03 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}09 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Đầu ra Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}60 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}17 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}19 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Một tập hợp chỉ chứa các phần tử duy nhất nhưng tại thời điểm tạo tập hợp, nhiều giá trị trùng lặp cũng có thể được truyền. Thứ tự của các phần tử trong một bộ không được xác định và không thể thay đổi. Loại phần tử trong một tập hợp không cần phải giống nhau, các giá trị loại dữ liệu hỗn hợp khác nhau cũng có thể được chuyển cho tập hợp. & NBSP; Đầu ra Initial set {'For', 'Geeks'} Elements of set: For Geeks True Một tập hợp chỉ chứa các phần tử duy nhất nhưng tại thời điểm tạo tập hợp, nhiều giá trị trùng lặp cũng có thể được truyền. Thứ tự của các phần tử trong một bộ không được xác định và không thể thay đổi. Loại phần tử trong một tập hợp không cần phải giống nhau, các giá trị loại dữ liệu hỗn hợp khác nhau cũng có thể được chuyển cho tập hợp. & NBSP;Các____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Initial set {'For', 'Geeks'} Elements of set: For Geeks True8 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}7 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__97____ Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}9 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__101 Python3____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Initial set {'For', 'Geeks'} Elements of set: For Geeks True8 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}7 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__ Các Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}57 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}61 The FrozenSet is: frozenset({'o', 'G', 'e', 's', 'r', 'F', 'k'}) Empty FrozenSet: frozenset()1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}61 Initial set: {1, 2, 3, 4, 5} Set after clearing all the elements: set()9 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}69 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}73 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}35 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}73 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}38 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}81 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}51 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}52 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}53 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}54 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 The FrozenSet is: frozenset({'o', 'G', 'e', 's', 'r', 'F', 'k'}) Empty FrozenSet: frozenset()1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}59 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}60 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}95 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}98 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Đầu ra Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12} Sử dụng phương thức pop ():Hàm pop () cũng có thể được sử dụng để xóa và trả về một phần tử khỏi tập hợp, nhưng nó chỉ xóa phần tử cuối cùng của tập hợp. & NBSP;
Python3____10 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}1 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}2 Initial set {'For', 'Geeks'} Elements of set: For Geeks True8 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}5 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}7 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0__ Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}42 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}43 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}35 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}38 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}81 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}83 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}0 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}53 Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after Removal of two elements: {1, 2, 3, 4, 7, 8, 9, 10, 11, 12} Set after Discarding two elements: {1, 2, 3, 4, 7, 10, 11, 12} Set after Removing a range of elements: {7, 10, 11, 12}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial blank Set: set() Set after Addition of Three elements: {8, 9, (6, 7)} Set after Addition of elements from 1-5: {1, 2, 3, (6, 7), 4, 5, 8, 9}57 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}37 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}40 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Đầu ra Initial Set: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Set after popping an element: {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Sử dụng phương thức pop ():Hàm pop () cũng có thể được sử dụng để xóa và trả về một phần tử khỏi tập hợp, nhưng nó chỉ xóa phần tử cuối cùng của tập hợp. & NBSP; Python3Lưu ý: Nếu tập hợp không được đặt hàng thì không có cách nào để xác định phần tử nào được bật bằng cách sử dụng hàm pop (). & Nbsp; Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}60 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}64 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}67 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}9 Đầu ra Initial set: {1, 2, 3, 4, 5} Set after clearing all the elements: set() Sử dụng phương thức pop (): in Python are immutable objects that only support methods and operators that produce a result without affecting the frozen set or sets to which they are applied. While elements of a set can be modified at any time, elements of the frozen set remain the same after creation. Hàm pop () cũng có thể được sử dụng để xóa và trả về một phần tử khỏi tập hợp, nhưng nó chỉ xóa phần tử cuối cùng của tập hợp. & NBSP; Python3Lưu ý: Nếu tập hợp không được đặt hàng thì không có cách nào để xác định phần tử nào được bật bằng cách sử dụng hàm pop (). & Nbsp; Sử dụng phương thức rõ ràng (): Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}96 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}99 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial set {'For', 'Geeks'} Elements of set: For Geeks True02 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}7 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Set after Addition of elements using Update: {4, 5, (6, 7), 10, 11}92 Initial set {'For', 'Geeks'} Elements of set: For Geeks True07 Đầu ra The FrozenSet is: frozenset({'o', 'G', 'e', 's', 'r', 'F', 'k'}) Empty FrozenSet: frozenset() Sử dụng phương thức pop ():Hàm pop () cũng có thể được sử dụng để xóa và trả về một phần tử khỏi tập hợp, nhưng nó chỉ xóa phần tử cuối cùng của tập hợp. & NBSP;Lưu ý: Nếu tập hợp không được đặt hàng thì không có cách nào để xác định phần tử nào được bật bằng cách sử dụng hàm pop (). & Nbsp; Sử dụng phương thức rõ ràng (): Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial set {'For', 'Geeks'} Elements of set: For Geeks True35 Initial set {'For', 'Geeks'} Elements of set: For Geeks True36 Để loại bỏ tất cả các phần tử khỏi hàm, clear () được sử dụng. & Nbsp; Các Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial set {'For', 'Geeks'} Elements of set: For Geeks True46 Initial set {'For', 'Geeks'} Elements of set: For Geeks True47 Các bộ đông lạnh trong Python là các đối tượng bất biến chỉ hỗ trợ các phương thức và toán tử tạo ra kết quả mà không ảnh hưởng đến bộ hoặc bộ đóng băng mà chúng được áp dụng. Mặc dù các phần tử của một tập hợp có thể được sửa đổi bất cứ lúc nào, các phần tử của bộ đông lạnh vẫn giữ nguyên sau khi tạo. & NBSP; Nếu không có tham số nào được thông qua, nó sẽ trả về một frozenset trống. & Nbsp; & nbsp; Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}4 Set with the use of Numbers: {1, 2, 3, 4, 5, 6} Set with the use of Mixed Values {1, 2, 'For', 4, 6, 'Geeks'}5 Initial set {'For', 'Geeks'} Elements of set: For Geeks True69 Initial set {'For', 'Geeks'} Elements of set: For Geeks True70 Đầu ra my_list as a set: {1, 2, 3, 4, 5, 6} my_str as a set: {'f', 'G', 'r', 'o', 's', 'k', 'e'} my_dict as a set: {1, 2, 3} Sử dụng phương thức pop ():
Các bài viết gần đây về bộ PythonĐặt chương trình
Liên kết hữu ích
Làm thế nào để bạn nhận được một mục cụ thể từ một bộ trong Python?Lấy phần tử đầu tiên của một tập hợp trong Python, chúng ta có thể truy cập mục đầu tiên trong tập hợp bằng cách sử dụng hàm iter (), chúng ta phải áp dụng phần tiếp theo để lấy phần tử đầu tiên. Chúng ta cũng có thể sử dụng phương thức đầu tiên () từ mô -đun Iteration_Utilities, sẽ trả về phần tử đầu tiên.by using the iter() function, we have to apply the next() to it to get the first element. We can also use the first() method from the iteration_utilities module, Which will return the first element.
Làm thế nào để bạn tìm thấy các yếu tố của một bộ?Bạn phải truy cập các yếu tố bằng cách sử dụng một iterator.Đặt myset;bộ của tôi.chèn (100);int setint = *myset.bắt đầu();using an iterator. set
Mục đặt trong Python là gì?Các bộ được sử dụng để lưu trữ nhiều mục trong một biến duy nhất.Set là một trong 4 loại dữ liệu tích hợp trong Python được sử dụng để lưu trữ các bộ sưu tập dữ liệu, 3 loại khác là danh sách, tuple và từ điển, tất cả đều có phẩm chất và cách sử dụng khác nhau.Một bộ là một bộ sưu tập không được đặt hàng, không thể thay đổi*và không được bảo vệ.used to store multiple items in a single variable. Set is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Tuple, and Dictionary, all with different qualities and usage. A set is a collection which is unordered, unchangeable*, and unindexed.
Làm thế nào để bạn kiểm tra xem một giá trị có mặt trong một bộ python?Phương pháp: 1 Sử dụng trong toán tử Đây là toán tử thành viên được sử dụng để kiểm tra xem giá trị đã cho có có trong tập hợp hay không.Nó sẽ trả về đúng nếu phần tử đã cho có mặt trong tập hợp, nếu không thì sai.Using in operator
This is an membership operator used to check whether the given value is present in set or not. It will return True if the given element is present in set , otherwise False. |