A tuple is an assortment of items which requested and permanent. Tuples are successions, very much like records. The contrasts among tuples and records are, the tuples can't be changed not normal for records and tuples use enclosures, though records utilize square sections. Making a tuple is pretty much as straightforward as putting diverse comma-isolated qualities. Alternatively you can put these comma-isolated qualities between enclosures moreover. For instance − tup1 = ('material science', 'science', 1997, 2000); tup2 = (1, 2, 3, 4, 5 ); tup3 = "a", "b", "c", "d"; The void tuple is composed as two enclosures containing nothing − tup1 = (); To compose a tuple containing a solitary worth you need to incorporate a comma, despite the fact that there is just one worth − tup1 = (50,); Like string files, tuple records start at 0, and they can be cut, linked, etc. Getting to Values in Tuples To get to values in tuple, u...
Global and local scope of Python variables The scope of a variable alludes to the places that you can see or access a variable. In the event that you characterize a variable at the high level of your content or module or note pad, this is a global variable: >>> my_var = 3 The variable is global because any Python capacity or class characterized in this module or scratch pad, can access this variable. For example: >>> def my_first_func(): ... # my_func can 'see' the global variable ... print('I see "my_var" = ', my_var, ' from "my_first_func"') >>> my_first_func() I see "my_var" = 3 from "my_first_func" Variables characterized inside a capacity or class, are not global. Just the capacity or class can see the variable: >>> def my_second_func(): ... a = 10 ... print('I see "a" = ', a, 'from "my_second_func"') >>> my_second_func() ...