Professional Documents
Culture Documents
Unit 4TH Model Answer (PWP)
Unit 4TH Model Answer (PWP)
Write Question first then , write the answer as per the note Remark on Answer in
Qus. Stepwise Hindi only to obtain full
No. given below marks mark
Note :- Read and understand the question and write appropriate answer in bi-lingal language by writing technical terminology in english only, Draw
simlifiedwel-label neat scheme,whenever necessary, which is easy to understand and recall and write the answer in bilingal language only so that
students should not face language problem to write the answer or they dont do chatting the answer or rattta-fication. Ans. should be written brifely
(Give stepwise marks)
Remark on
Answer in
Write Question first then , write the answer as per the note Hindi only to
obtain full
Qus. No. given below Stepwise marks mark
Explain Local and Global variable.
Q.No.1
Local Variables: Local variables are those which are initialized inside a
function and belongs only to that particular function. It cannot be
2 अंक (1 अं क
accessed anywhere outside the function . local variable वे होते ह जो िकसी
function के अं दर start िकए जाते ह और केवल उस particular function से each)
संबंिधत होते ह। इसे function के बाहर कहीं भी accessed नहीं िकया जा सकता
है ।
Example:
S-22
def f(): # local variable
s = "I love Python Programming"
print(s) # Driver code f()
Output :
I love Python Programming
Global Variables: The global variables are those which are defined
outside any function and which are accessible throughout the program
i.e. inside and outside of every function. Global Variables वे होते ह जो
िकसी function के बाहर defined होते ह और जो पूरे program म यानी हर
function के अं दर और बाहर प ंच यो होते ह।
Example:
# This function uses global variable s
def f():
print("Inside Function", s)
# Global scope
s = "I love Python Programming"
f()
print("Outside Function", s)
Output:
Inside Function I love Python Programming
Outside Function I love Python Programming
Syntax-3:
from import as Example:
>>> from pkg.mod1 import m1 as module
>>> module() first module You can import modules with these
statements as well:
from import [, ...] from import as
Example:
>>> from pkg import mod1
>>> mod1.m1()
First module
Q.No.7
1) Write python program using module, show how to write and use
module by importing it.
2) Example module. How to define module.