You are on page 1of 6

PYTHON

WEEK END ASSIGNMENT-2

QUESTION -1

CASE -1

 When we declare the x variable globally so that we can access it from inside and outside the function.
That’s why we dint get any error.

CASE -2

 But in this case we just assigned a value to variable x within the function and the print statement within
the funtion gets printed and outside the function poped an error.
QUESTION -2

Case -1

 The same concept as we dealt before, yes we have a function func1() which returns the value of x. But
the function doesnot have any return statement. So the value of x declared outside the fuction is
displayed as output.

Case -2

 Now , we have the value 50, Since we have called the function func1() which returns value of inner x
that is 50 and stores in the memory location of s. when we now print x it will absolutely be 50.
QUESTION -3

 Here I have changed the second value of List a with indexing.

QUESTION -4

 By printing t[1], the string ‘program’ in the Tuple t() will be displayed.

QUESTION -5

 By printing t[1], the string ‘program’ in the Tuple t() will be displayed.
QUESTION -6

 The identity operators are is and isnot.Here if i use is the output will be false, if I use is not the output
will be true as below.

QUESTION -7

 The empty list and zero are falsy values. So when I give 1 and some values in the list I get truthy values.

QUESTION -8

 The membership operators are in and not in.


QUESTION -9

 Intersection of two given sets is the largest set which contains all the elements that are common to both
the sets. Intersection of two given sets A and B is a set which consists of all the elements which are
common to both A and B.

QUESTION -10

 The identity operator are is and is not.

By,

N. Harismita,

16MSS017

You might also like