Python Module 1
Python Module 1
Python Basics
APPLICATION
DEVELOPMENT USING
PYTHON-18CS55
Sneha N P
Assistant Professor
Dept. of Computer Science & Engineering
AIT, Bangalore
Arguments
• When creating a function using the def statement, you can specify what the return value should be
with a return statement.
• When an expression is used with a return statement, the return value is what this expression evaluates
to.
• 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.
• replace the default separating string by passing the sep keyword argument.
Enter the following into the interactive shell:
• Variables that are assigned outside all functions are said to exist in the global
scope.
• A variable that exists in a local scope is called a local variable, while a variable
that exists in the global scope is called a global variable.
• Code in a function’s local scope cannot use variables in any other local scope.
• You can use the same name for different variables if they are in different scopes. That
is, there can be a local variable named spam and a global variable also named spam.
• Consider this program, which will cause an error when you run it:
def spam():
eggs = 31337
spam()
print(eggs)
1. If a variable is being used in the global scope (that is, outside of all functions), then it is
always a global variable.