Functions
6.1 Introduction to Functions
- 6.1.1 Meaning of Function
- 6.1.2 Need for Functions
- 6.1.3 Advantages of Functions
- 6.1.4 Types of Functions in Python
- 6.1.5 Built-in Functions
- 6.1.6 User-Defined Functions
6.2 Top-Down Approach of Problem Solving
- 6.2.1 Meaning of Top-Down Approach
- 6.2.2 Steps of Top-Down Problem Solving
- 6.2.3 Problem Decomposition
- 6.2.4 Example of Top-Down Approach
6.3 Modular Programming and Functions
- 6.3.1 Meaning of Modular Programming
- 6.3.2 Need for Modular Programming
- 6.3.3 Advantages of Modular Programming
- 6.3.4 Functions as Modules
- 6.3.5 Example of Modular Programming
6.4 Defining and Calling Functions
- 6.4.1 Function Definition
- 6.4.2 Function Calling
- 6.4.3 Syntax of Function
- 6.4.4 Function with No Parameters
- 6.4.5 Function with Parameters
- 6.4.6 Function with Return Value
6.5 Function Parameters
- 6.5.1 Meaning of Parameters
- 6.5.2 Actual and Formal Parameters
- 6.5.3 Positional Arguments
- 6.5.4 Parameter Passing
- 6.5.5 Multiple Parameters
6.6 Local Variables
- 6.6.1 Meaning of Local Variable
- 6.6.2 Scope of Local Variable
- 6.6.3 Local Variable Example
- 6.6.4 Local vs Global Variables
6.7 The return Statement
- 6.7.1 Introduction to return
- 6.7.2 Returning a Single Value
- 6.7.3 Returning Multiple Values
- 6.7.4 Function Without return
- 6.7.5 Difference Between print() and return
6.8 DocStrings
- 6.8.1 Meaning of DocString
- 6.8.2 Writing a DocString
- 6.8.3 Accessing DocString
- 6.8.4 Importance of DocStrings
6.9 Global Statement
- 6.9.1 Global Variables
- 6.9.2 global Statement
- 6.9.3 Modifying Global Variables
- 6.9.4 Local and Global Variable Example
6.10 Default Argument Values
- 6.10.1 Meaning of Default Arguments
- 6.10.2 Defining Default Arguments
- 6.10.3 Calling Function with Default Arguments
- 6.10.4 Multiple Default Arguments
6.11 Keyword Arguments
- 6.11.1 Meaning of Keyword Arguments
- 6.11.2 Using Keyword Arguments
- 6.11.3 Positional vs Keyword Arguments
- 6.11.4 Advantages of Keyword Arguments
6.12 VarArgs Parameters
- 6.12.1 Variable-Length Arguments
- 6.12.2 *args
- 6.12.3 **kwargs
- 6.12.4 Difference Between *args and **kwargs
- 6.12.5 Examples of VarArgs Functions
6.13 Library / Built-in Functions
6.13.1 Input and Output Functions
6.13.2 String Functions
- count()
- find()
- rfind()
- capitalize()
- title()
- lower()
- upper()
- swapcase()
- islower()
- isupper()
- istitle()
- replace()
- strip()
- lstrip()
- rstrip()
- split()
- partition()
- join()
- isspace()
- isalpha()
- isdigit()
- isalnum()
- startswith()
- endswith()
- encode()
- decode()
6.13.3 String Slicing
- 6.13.3.1 String Indexing
- 6.13.3.2 String Slicing
- 6.13.3.3 Negative Indexing
- 6.13.3.4 Slicing with Step
- 6.13.3.5 Reverse String Using Slicing
6.13.4 String Membership
- in Operator
- not in Operator
- Searching Substrings
6.13.5 Pattern Matching
- 6.13.5.1 Introduction to Pattern Matching
- 6.13.5.2 Basic Pattern Searching
- 6.13.5.3 String Pattern Examples
6.14 Numeric Functions
- 6.14.1 eval()
- 6.14.2 max()
- 6.14.3 min()
- 6.14.4 pow()
- 6.14.5 round()
- 6.14.6 int()
- 6.14.7 random()
- 6.14.8 ceil()
- 6.14.9 floor()
- 6.14.10 sqrt()