python questions

1.What is the value of the following expression:

sеt (rаngе (0, 20, 3)) & sеt (rangе (0, 20, 2))

{0, 6, 12, 18}

{0, 2, 3, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18}

{3, 9, 15}

{2, 3, 4, 8, 9, 10, 14, 15, 16}

. 2.

Which operators are applicable to sets? (Check all that apply.)

+

*

&

|

^

/

in

. 3.

Which expression correctly changes the tail (the last element) of the middle item in the following

tuple:

foo=(12, [“a”, “n”, “d”, “y”], set (“andy”))

foo[1][-1] = “a”

foo[0][0] = “a”

Tuples are immutable and cannot be changed.

The tuple foo has items of different data types and is illegal.

. 4.

Which data type cannot be used as a key in a dictionary?

list

int

float

string

. 5.

Which data structures could be used instead of the following dictionary without any loss of

information and functionality, including possible modifications both of element names and their

weights?

elements = {“H” : 1, “He” : 4, “Li” : 7, “Be” : 9}

names = [“H”, “He”, “Li”, “Be”]

weights =

Leave a Reply

Your email address will not be published. Required fields are marked *