Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
34 views6 pages

PYTHON ASSESSMENT 16mss017

This document contains the solutions to 10 questions on a Python assignment. It discusses global vs local variables in functions, returning values from functions, changing list values by index, using tuples, identity operators like is and is not, membership operators like in and not in, set intersection, and falsy values like empty lists and zero. The key concepts covered are variable scoping, returning values, basic data structures, operators, and set operations.

Uploaded by

Harismita Nagraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views6 pages

PYTHON ASSESSMENT 16mss017

This document contains the solutions to 10 questions on a Python assignment. It discusses global vs local variables in functions, returning values from functions, changing list values by index, using tuples, identity operators like is and is not, membership operators like in and not in, set intersection, and falsy values like empty lists and zero. The key concepts covered are variable scoping, returning values, basic data structures, operators, and set operations.

Uploaded by

Harismita Nagraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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