Pymodule1 (Chapter 3)
Pymodule1 (Chapter 3)
• keyword arguments are identified by the keyword put before them in the function call.
• Keyword arguments are often used for optional parameters.
• For example, the print() function has the optional parameters end and sep to specify what
should be printed at the end of its arguments and between its arguments (separating them),
respectively.
• Example— Output—
• def team(name, project):
• print(name, "is working on an", project) FemCode is working on
• team(project = "Edpresso", name = 'FemCode')
an Edpresso
PREPARED BY- MIS.ITISHREE BARIK
ASST. PROFESSOR, DEPT OF CSE, SIR MVIT
3.5Python Scope of Variables
• In Python, variables are the containers for storing data values.
• Unlike other languages like C/C++/JAVA, Python is not “statically typed”. We do not need to
declare variables before using them or declare their type. A variable is created the moment we
first assign a value to it.
• Python Scope variable
• The location where we can find a variable and also access it if required is called the scope of a
variable.
• It is 2 types—
1. Local variable
2. Global variable
PREPARED BY- MIS.ITISHREE BARIK
ASST. PROFESSOR, DEPT OF CSE, SIR MVIT
3.5.1.Local variable
• These are the variable which is store in local space and can be accessed only within the boundaries of the function.
• Example— Output—
a=10
def sam(): 12
a=100
print(a)
10
print(a+2) 100
print(a+2)
print(a) 102
sam()
print(a) 10
• print(result)
• except:
• print("Error: Denominator cannot be 0.")
• guess_the_number()