Tuples & Sets

¡Supera tus tareas y exámenes ahora con Quizwiz!

Intersection of A and B is a set of elements that are common in both sets.Intersection is performed using ______operator. Same can be accomplished using the method ________ .

& , intersection ( )

Union of A and B is a set of all elements from both sets. Union is performed using _____operator. Same can be accomplished using the method ____

| , union ( )

3 usual ways to access data in a tuple: 1-through ______ like with list (list [ 0] for example) 2- using a _____ _______ 3- ________operator ' : ' as with list

Index, for loop , slicing

A set is an _______ collection of items. Every element is _______ and must be _______.However, the set itself is _________. We can add or remove items from it.

unordered, unique, immutable,mutable.

A set is created by placing all the items (elements) inside ________, separated by _________ or by using the built-in function ________. But a set cannot have a ______ element, like list, set or dictionary, as its element.

{}, comma, set () , mutable

Difference of A and B ( A - B ) is a set of elements that are only in A but not in B . Similarly, B - A is a set of element in B but not in A . Difference is performed using ____ operator. Same can be accomplished using the method ________.

- , difference ( )

Unlike list Tuples are ______________ .A tuple can have any number of _______ and they may be of different _______ (integer, float, list, string, etc.

Immutable, items, types

A tuple is created by placing all the items (elements) inside ____________ , separated by __________

Parentheses, commas

The difference between discard ( ) and remove ( ) is that, while using discard() if the item does not exist in the set, it remains ______. But remove() will raise _______ in such condition. We can also remove all items from a set using_______.

Unchanged, an error, clear ( ).

Symmetric Difference of A and B is a set of elements in both A and B except those that are common in both. Symmetric difference is performed using _______ operator. Same can be accomplished using the method ____________.

^, symmetric_difference ( )

Adding elements into a set, ______ adds an element into the set , __________ update the set with the union of itself and others

add ( ) , update ( )

We can add single element to a set ,using the _______method and multiple elements using the _______method. The ______method can take tuples, lists, strings or other sets as its argument. In all cases, duplicates are avoided.

add ( ), update ( ), update ( )

Tuples 2 methods: 1- ________returns the number of x items 2- __________returns the the ________of the first item that is equal to x

count (x) , index (x), index

A particular item can be removed from set using methods, _______ and _________.

discard ( ) , remove ( )

.To make a set without any elements we use the ______function without any _______. Empty curly braces {} will make an empty ________ in Python

set ( ), argument, dictionary

Turning a given list list1= [10,20,30] into a tuple using a built-in function?

tuple (list1)


Conjuntos de estudio relacionados

10th grade Biology Unit 1: Lesson 6

View Set

PCAP- programing Essentials in Python

View Set

OB Adaptive quizzing test 3 CH 33

View Set

AWS Cloud Practitioner Exam Questions

View Set